From 9fa7594b12358137d0bfa8b2e0961e500633ff57 Mon Sep 17 00:00:00 2001 From: Phyks Date: Thu, 1 Aug 2013 21:29:07 +0200 Subject: [PATCH] Added a README file and updated some code (flake8 + help message) --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++ generateur.c | 2 +- generateur_partition.py | 13 ++++++++--- 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8a1c9e --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +(Bad) Artificial Song Generator +=============================== + +This is just a simple C code to handle wave files (see files wave_stuf.* for the functions) and a simple application to generating purely artificial sounds (just by creating a wave file with values from a sine wave at the good frequency to make a note. + +### Included files are : + +* _examples_ folder with some examples music sheets and the resulting generated wave files +* _generateur.c_ which is the main program +* _generateur_partition.py_ which is just a simple program to generate basic music sheet to use with the main program +* _wave_stuff.*_ which are the functions to handle wave files + +## Usage of the main program + +The main program should be compiled using the makefile. + +To use it, just run from command line : +generateur.out partition output.wav bpm silence where + +* _partition_ is the path to the music sheet you want to generate +* _output.wav_ is the resulting wave files +* _bpm_ is the speed of the song (in bpm) +* _silence_ is an integer that should be set to 1 to add silences between notes + +## Usage of the basic music sheet generator + +This program allows you to write a simple music sheet without always looking for the correspondance between note and frequency. It is very basic and only allows you to use notes amongst : + +* RE, MI, FA, SOL, LA, SI, DO (where LA is 440Hz) +* RE2, MI2, FA2, SOL2, LA2, SI2, DO2 (where LA is 880Hz). + +Length is any integer you want. It will define the length of the note (play with both length and bpm params to get what you want). + +You can use the -o (--output) option with a filename as argument to store the generated music sheet to this specific file. + +## License +### TLDR; + I don't give a damn to anything you can do using this code. It would just be nice to + quote where the original code comes from. + + +-------------------------------------------------------------------------------- + "THE NO-ALCOHOL BEER-WARE LICENSE" (Revision 42): + + Phyks (phyks@phyks.me) wrote this file. As long as you retain this notice you + can do whatever you want with this stuff (and you can also do whatever you want + with this stuff without retaining it, but that's not cool... :/ ). If we meet some + day, and you think this stuff is worth it, you can buy me a beer soda + in return. + Phyks +--------------------------------------------------------------------------------- diff --git a/generateur.c b/generateur.c index 8c066fa..dc5d286 100644 --- a/generateur.c +++ b/generateur.c @@ -63,7 +63,7 @@ int main(int argc, char **argv) { if (argc < 5) { - fprintf(stderr,"Usage: %s partition output.wav bpm silence\n",argv[0]); + fprintf(stderr,"Usage: %s partition output.wav bpm silence\nsilence should be 1 to add silence between notes.\n",argv[0]); return 0; } diff --git a/generateur_partition.py b/generateur_partition.py index 06aaffe..26f990d 100755 --- a/generateur_partition.py +++ b/generateur_partition.py @@ -12,18 +12,25 @@ except getopt.GetoptError: for opt, arg in opts: if opt in ("-h", "--help"): print("Music sheet generator for the sound player. Usage :") - print("-h \t --help \t Displays this help message") + print("-h \t\t --help \t Displays this help message") print("-o file \t --output file \t Save the generated music sheet to " "the specified file") + print("\nAllowed values for notes are RE, MI, FA, SOL, LA, SI, DO" + "(corresponding to LA = 440Hz) and RE2, MI2, FA2, SOL2, LA2, " + "SI2, DO2 (corresponding to LA2 = 880Hz)") + + print("\nTo quit, just enter \"quit\" as note") + sys.exit() + elif opt in ("-o", "--output"): output = arg continue_while = True notes = {"RE": 294, "MI": 330, "FA": 349, "SOL": 392, "LA": 440, "SI": 494, - "DO": 523, "RE2": 587, "MI2": 659, "FA2": 699, "SOL2": 794, "LA2": 880, - "SI2": 988} + "DO": 523, "RE2": 587, "MI2": 659, "FA2": 699, "SOL2": 794, + "LA2": 880, "SI2": 988} partition = '' while continue_while: