/*Holger Berg*/ /*Introduction to Programming*/ /*Assignment I*/ /*Algorithmic Sequencer Program*/ /*This is a program that will play a score contained in a text file.*/ #include #include #include #include #include "WavPlay.h" /*I create char variable with 2 arrays: 8 dimensional array for 8 sound files I use and 10 dimensional array for the file names*/ char filemap[8][10] = {"bassA.wav", "bassB.wav", "bassC.wav", "bassD.wav", "bassE.wav", "bassF.wav", "bassG.wav", "crash.wav"}; /*I create a function - playNoteEx - which will make the PlayWave to play the notes */ void playNoteEx(int note) { PlayWave(filemap[note]); } /* I create playNote function which will execute PlayNoteEx function */ void playNote(char note) { /*The letters (in the text file) are omitted the numerical value. That's why I created the 8 dimensional array above. So, for example, if the program reads the first letter in the text A, then the playNoteEx calls for playWav to play the first note defined with filemap variable*/ switch (note) { /*Switch case statements are a substitute for long if statements. The value of the variable given into switch is compared to the value following each of the cases, and when one value matches the value of the variable, the computer continues executing the program from that point. */ case 'A': playNoteEx(0); break; case 'B': playNoteEx(1); break; case 'C': playNoteEx(2); break; case 'D': playNoteEx(3); break; case 'E': playNoteEx(4); break; case 'F': playNoteEx(5); break; case 'G': playNoteEx(6); break; case 'Z': playNoteEx(7); break; default: break; } } /*A function to play the score normally*/ void playNormally(char* score, int length) { int i; for(i=0;i