Music examples for original Gamebuino?

Development

exocet

6 years 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 6 years 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 6 years 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

6 years 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 6 years 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 6 years 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...).

Aurélien Rodot

6 years 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.


Aurélien Rodot

NEW 6 years 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 6 years 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 6 years 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 6 years 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

Duration
Note FR
Note Gamebuino
4
Do
C-3
4
Do
C-3
8
Re
D-3
8
Do
C-3
8
Fa
F-3
16
Mi
E-3
4
Do
C-3
4
Do
C-3
8
Re
D-3
8
Do
C-3
8
Sol
G-3
8
Fa
F-3
8
Silence
Silence
4
Do
C-3
4
Do
C-3
8
Do+
C-4
8
La
A-3
8
Fa
F-3
8
Mi
E-3
8
Re
D-3
4
Fa#
F#3
4
Fa#
F#3
8
La
A-3
8
Fa
F-3
8
Sol
G-3
32
Fa
F-3


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

Duration
Note
Transpose
2
C-5
2
2
C-5
2
4
D-5
2
4
C-5
2
4
F-5
2
8
E-5
2
2
C-5
2
2
C-5
2
4
D-5
2
4
C-5
2
4
G-5
2
4
F-5
2
4
Silence
2
2
C-5
2
2
C-5
2
4
C-6
2
4
A-5
2
4
F-5
2
4
E-5
2
4
D-5
2
2
F#5
2
2
F#5
2
4
A-5
2
4
F-5
2
4
G-5
2
16
F-5
2


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"));
}
}


jicehel

NEW 6 years ago

Nobody have an idea of my mistake or of the problem ? Not easy as the subjet of the music isn't very used atm. If someone find my error and can explain how i could solve it, it would be great anyway. It's maybe easy (probably something i missed)

jicehel

NEW 6 years ago

Cool Drakker m'a expliqué mon erreur. Je corrigerais demain. En attendant, voici une petite musique:


#include <SPI.h> 
#include <Gamebuino.h> 
Gamebuino gb;   
int notes[]={21,4,14,4,17,2,19,2,21,4,14,4,17,2,19,2,21,4,14,4,17,2,19,2,21,4,14,4,
        17,2,19,2,21,4,14,4,18,2,19,2,21,4,14,4,18,2,19,2,21,4,14,4,18,2,19,2, 
       21,4,14,4,18,2,19,2,21,4,14,4,17,2,19,2,21,4,14,4,17,2,19,2,16,4, 9,4, 
       12,2,14,2,16,4, 9,4,12,2,14,2,16,4, 9,4,12,2,14,2,16,4, 9,4,12,2,14,2,
        16,8,19,8,12,8,17,2,16,2,19,8,12,8,16,2,14,4,10,2,12,21,4,7,4,10,2,12,
        21,4,7,4,10,2,12,214,4,7,4,21,8,14,8,17,2,19,2,21,8,14,8,17,2,19,2,16,4,
         9,4,12,2,14,2,16,4,9,4,12,2,14,2,16,4,9,4,12,2,14,2,16,4,9,4,12,2,14,2,16,4};
   int tempo = 250;
  int joue_note;
 void setup(){  
  gb.begin();
  gb.titleScreen(F("Music: Games of Throne"));
  // gb.sound.changeInstrumentSet(1,0);
  gb.setFrameRate(4);
  joue_note = 0;
 } 


void loop(){
 if(gb.update()){
    gb.display.print("Music: Games of Throne");
    if (joue_note < 103) {
      gb.sound.playNote(notes[joue_note],notes[joue_note+1]*tempo,0);
      joue_note = joue_note + 2;
      } else gb.sound.playNote(63,500,0);
  }
 }

Aurélien Rodot

6 years ago

Juste une petite remarque, tu peux formater ton code correctement, c'est par là => 

Aurélien Rodot

NEW 6 years ago

jicehel jicehel

Juste une petite remarque, tu peux formater ton code correctement, c'est par là => 

jicehel

NEW 6 years ago

Oh, thanks i didn't saw it. Alot better as code  ;)

I'll anothe try with pattern with this music. Last try was missed (music was playing but not the notes i had enter in Excel, pobably a personnal error)

jicehel

NEW 6 years ago

Rodot if you have time could you look upper for the problem i have to make pattern. I have posted the original notes (french), the english notation as i have translated them, the original duration and the corresponding french name (noire, ronde, croche, ...) and below, i have posted the columns in the Excel files for the pattern0 and below again, i have posted the code used.

Maybe i should add some instructions but nothing else seems important to play music so i think i have make an error in the use of the Excel file to generate the pattern. If you remember how to use it, the error can maybe be easy to find for you. (I hope it  ;) )

If i understand it, you can be sure than alot can understand it and we could have more music in games  ;)

Codnpix

NEW 5 years ago

Hello, is there something new regarding sound patterns documentation and how to generate chiptune music with the Meta ?

I found documentation in the reference for playing simple tones, and I also found the FX tool. But it gets more complicated when I try to understand how to make a pattern with all of this and play it in a game :).

Thanks if someone has any more information !

Sorunome

5 years ago

For the META you don't really need pattern stuff - you can just stream a WAV file from the SD card! (8-bit, unsigned, singel channel, 44.2MHz)

If you really want to look into patterns, they work the same as on the classic, except that you only have the square instrument, none other.

Sorunome

NEW 5 years ago

Codnpix Codnpix

For the META you don't really need pattern stuff - you can just stream a WAV file from the SD card! (8-bit, unsigned, singel channel, 44.2MHz)

If you really want to look into patterns, they work the same as on the classic, except that you only have the square instrument, none other.