Music examples for original Gamebuino?

Development

exocet

1 week ago

Hi,

I'm curious to hear what kind of music the original Gamebuino is capable of playing and I'd like to test adding music to a program, but I can't find any examples of songs produced either with FreddyWild's or Rodot's tracker. Anyone got that and would be happy to share it?

Thanks!

jicehel

NEW 2 days ago

I have reply you on the old ofrum what it's a subject that i have to test too. I'll try tonight. I know how to play noises (sounds), i have to look how to manage patern and paterns to play music. It's should not be hard. I'll try with some easy songs as 'Happy Birthday' just to have easy example. If i success i'll be able to add music in games and i'll of course share the program here (i think i'll stop going on the old forum as this one is alot more animated  ;) )

jicehel

NEW 2 days ago

So i have try... i have not yet understood how paterns / tracks are working. I said i will test and post, so i 'll post a code to play music... It's not a good way to do it as i have not put the notes in an array to play it in the loop. I just call a sub... it's a lazzy solution because it's late here and i'll go sleeping but it's play music   ;)


// Demo de musique sans utiliser les fonctions spéciales des librairies
// "Happy bithday" song just because it's easy


#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

int pinSpeaker=3; // définition du PIN de sortie du buzzer

void setup(){
gb.begin();
gb.titleScreen(F("Demo - Happy Birthday"));
// Instruments
// Instruments allow to play different kinds of sounds, not just plain square waves. It allows you to add variations in the sound of each note.
// An instrument is a succession of "steps", and each "step" has the following characteristics:
// step duration in number of frames (from 0 to 63)
// step waveform, it defines if this step should be played either using square wave or noise.
// step volume (from 0 to 7), it allows to create a volume envelope.
// pitch offset (from 0 to 63), to allow you to add arpeggio, glissando for example. We'll see later that you can also use commands to add effects to certain notes.
// Each instrument has a "last step looping" attribute. When a note duration is longer than the instrument it's played with, the instrument will loop on the last X steps. Or won't loop if it's set to 0. Note: You can't directly access to this layer. You can't play an "instrument", you have to play a "note" using an "instrument".

// gb.sound.command(CMD_INSTRUMENT, 1, 0, 3);

}

// fonction pour produire un son avec le buzzer
void joueSon(long duree, int frequence) {
duree *= 1000;
int period = (1.0/frequence)*1000000;
long temps_passe=0;

while (temps_passe < duree) {
digitalWrite(pinSpeaker,HIGH);
delayMicroseconds(period/2);
digitalWrite(pinSpeaker,LOW);
delayMicroseconds(period/2);
temps_passe+=period;
}
}

int noire=0;
int blanche=1;
int croche=2;
int ronde=3;

void joueNote(const char* note, int tempo) {

//int c=375;
int c=200;
int temps=300;
if (tempo==noire) {temps=2*c; }
else if (tempo==blanche) {temps=4*c; }
else if (tempo==croche) {temps=c; }
else if (tempo==ronde) {temps=8*c; }

int inter=100;
if (note == "Do") { joueSon(temps, 523); delay(inter);}
else if (note == "Re") { joueSon(temps, 587); delay(inter);}
else if (note == "Mi") { joueSon(temps, 659); delay(inter);}
else if (note == "Fa") { joueSon(temps, 698.5); delay(inter);}
else if (note == "Sol") { joueSon(temps, 784); delay(inter);}
else if (note == "La") { joueSon(temps, 880); delay(inter);}
else if (note == "Si") { joueSon(temps, 988); delay(inter);}
else if (note == "Sib") { joueSon(temps, 932); delay(inter);}
else if (note == "Do+") { joueSon(temps, 1046.5); delay(inter);}
else if (note == "Silence") { joueSon(0, 0); delay(inter);}
}

void joueHappyBirthday() {
// Première mesure
joueNote("Do",croche);
joueNote("Do",croche);
joueNote("Re",noire);
joueNote("Do",noire);
// Deuxième mesure
joueNote("Fa",noire);
joueNote("Mi",blanche);
// Troisième mesure
joueNote("Do",croche);
joueNote("Do",croche);
joueNote("Re",noire);
joueNote("Do",noire);
// Quatrième mesure
joueNote("Sol",noire);
joueNote("Fa",noire);
joueNote("Silence",noire);
// Cinquième mesure
joueNote("Do",croche);
joueNote("Do",croche);
joueNote("Do+",noire);
joueNote("La",noire);
// Sixième mesure
joueNote("Fa",noire);
joueNote("Mi",noire);
joueNote("Re",noire);
// Septième mesure
joueNote("Sib",croche);
joueNote("Sib",croche);
joueNote("La",noire);
joueNote("Fa",noire);
// Huitième mesure
joueNote("Sol",noire);
joueNote("Fa",ronde);
}

void loop() {
if(gb.update()){
//display some fancy stuff
gb.display.cursorX = -gb.frameCount/4;
gb.display.cursorY = 8;
gb.display.print("Music: Happy Birthday - First code of music by Jicehel");
joueHappyBirthday();
}

if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("Demo - Happy Birthday"));
}
}


exocet

13 hours ago

Thanks for your reply! I missed the one on the "classic" forum because I got an error message when posting there originally so I assumed it didn't go through and that the old forum was closed...


I've played a bit more with FreddyWild's tracker and I managed to make a simple test song with it. I still wonder what could be achieved by someone musically gifted though :)

jicehel

NEW 2 days ago

i have see with playnote that notes have numbers but i don't know how to do sharps and flats ('dièses' et 'bemols'), duration is easy to understand and chanel too. after, i have not understand how to put them in patterns. For tracks, as i understand, you make an array of patterns.

The part of the paterns isn't in the references. The part sound of the tutorial explain his part but i don't understand how to transform notes to be able to use them in patterns. If someone can explain me this two points: sharps and flats and use notes in paterns, i'll take it  ;)

jicehel

NEW 23 hours ago

Hum nobody know how to transform the informations of your notes into patterns ? For me, this part isn't explain in the sound part of the tutorial "sound" on http://legacy.gamebuino.com/wiki/index.php?title=Sound
It's written: "A pattern is a mixed array containing notes and commands" but not example to explain how to fill this array.

Else, i would play melody with notes but in the text, i hve not understood how to play a "si bemol" (Bb or B-flat in english). How it's works with playNote(pitch, duration, channel) ? I seen nothing about that. 

I have see Rodot sound example but patterns are a list of hexadecimal values and without comments to explain how to transform your notes into the list of values, i don't understand how code the melody (OK, "Happy birthday" is an easy melody, but it's an example...).

Rodot

23 hours ago

Yes the sound library was never documented in details... and right now we focus on the META. Although you can find some information in this java tracker source code : https://github.com/Rodot/Tracker or in this Excel spreadsheet that contains both a tracker and encoding information.


Rodot

NEW 23 hours ago

jicehel jicehel

Yes the sound library was never documented in details... and right now we focus on the META. Although you can find some information in this java tracker source code : https://github.com/Rodot/Tracker or in this Excel spreadsheet that contains both a tracker and encoding information.


jicehel

NEW 22 hours ago

Yes, thanks alot Rodot, the Excel give keys to understand... I could never understand how to code a track without it.

I'll try to use it tonight to code my happy birthday theme.

After if i success, i'll try your tracker who do the job for us if i have well understood.

With that we can hope to have more music option in the games and many artists to make new good free music to use in games or coder who will encode existing music.

exocet

NEW 13 hours ago

jicehel jicehel

Thanks for your reply! I missed the one on the "classic" forum because I got an error message when posting there originally so I assumed it didn't go through and that the old forum was closed...


I've played a bit more with FreddyWild's tracker and I managed to make a simple test song with it. I still wonder what could be achieved by someone musically gifted though :)

jicehel

NEW 12 hours ago

Hum not so easy... I have try to convert the notes to put them in Excel

For duration i had done 4 = croche; 8 = noire ; 16 = blanche ; 32 = ronde

DurationNote FRNote Gamebuino
4DoC-3
4DoC-3
8ReD-3
8DoC-3
8FaF-3
16MiE-3
4DoC-3
4DoC-3
8ReD-3
8DoC-3
8SolG-3
8FaF-3
8SilenceSilence
4DoC-3
4DoC-3
8Do+C-4
8LaA-3
8FaF-3
8MiE-3
8ReD-3
4Fa#F#3
4Fa#F#3
8LaA-3
8FaF-3
8SolG-3
32FaF-3


As the sound wasn't was i expected i have try to go higher and to accelerate the music, it's made:

DurationNoteTranspose
2C-52
2C-52
4D-52
4C-52
4F-52
8E-52
2C-52
2C-52
4D-52
4C-52
4G-52
4F-52
4Silence2
2C-52
2C-52
4C-62
4A-52
4F-52
4E-52
4D-52
2F#52
2F#52
4A-52
4F-52
4G-52
16F-52


But the music isn't at all the Happy birthday i was expected.

I put the program below. I make probably a mistake but i haven't understood what it was:

// Demo de musique (not woking, the song isn't what expected by me ...)
// "Happy bithday" song just because it's easy


#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

void setup(){
gb.begin();
gb.titleScreen(F("Demo - Happy Birthday"));
gb.setFrameRate(60);

//patterns
const unsigned int pattern0[] PROGMEM = {0x268,0x268,0x470,0x468,0x47C,0x878,0x268,0x268,0x470,0x468,0x484,0x47C,0x4FC,0x268,0x268,0x498,0x48C,0x47C,0x478,0x470,0x280,0x280,0x48C,0x47C,0x484,0x107C,0x0000};


gb.sound.playPattern(pattern0,0);
}


void loop() {
if(gb.update()){
//display some fancy stuff
gb.display.cursorX = -gb.frameCount/4;
gb.display.cursorY = 8;
gb.display.print("Music: Happy Birthday - First code of music by Jicehel");
}

if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("Demo - Happy Birthday"));
}
}


You must be logged in in order to post a message on the forum

Log in