How to add sound?


#21

@filmote … I’ll be back with you in a moment

@Hanski … PlayMusic example worked right out of the box


#22

@filmote - clarification needed. Are you talking about the original ArduboyTones library or something that is inside Arduboy2 lib ?


#23

Definitely the ArduboyTones library.

Just now? What might I be doing wrong then??


#24

You mean this:
https://mlxxxp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/html/classArduboy2Audio.html

Pokitto equivalent is here:

https://www.pokitto.com/api/class_pokitto_1_1_sound.html

Agreed, there is just functions listed. No further info. Even if some other functions have more info, we are clearly missing description and examples for each.

But, for a newcomer like me, it is not so straightforward to find an info about the Arduboy tones functions either. all I can find is the above and this: https://mlxxxp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/html/classBeepPin1.html#aac2fe898dea4a841cdf26a5daabb2c36.
Neither is talking about sequence of tones.


#25

#26

@filmote : 101starships has a melody, exactly in the way you need

it is using the Gamebuino system (port of GB classic game)

While I am digging up the ArduboyTones port I made (must be 2 yrs ago) you might take a look at how 101Starships does it

EDIT: my_settings.h for that project

#define PROJ_STREAMING_MUSIC 1
#define PROJ_GBSOUND 1
#define PROJ_AUD_FREQ 22050

EDIT: took out the unnecessary defines


#27

Just checking, @filmote and @jonne, are you both talking about working on HW? Not in the Emulator or Simulator?


#28

@jonne As no one wants to write documentation, could we have a documentation contest to improve the situation?


#29

Works in HW and Simulator, emulator - as we know - does not support sound so well

@filmote , what IDE are you using?


#30

I am using FemtoIDE and I have tested PlayMusic on physical hardware and I get no sound. When you said …

… are you talking about the example in the repo as it exists now?

@Hanski . I am talking about the AruboyTones library that @uxe posted.


#31

Yes. The example in the repo, compiled in embitz, no changes.

I think I need to try it in FemtoIDE also


#32

Oh … so I can get different results because I am using FemtoIDE?


#33

I don’t know, it needs to be checked.

The reason why you get no sound is still to be solved


#34

That should not be the case, as it uses the same PokittoLib, but have to checked.


#35

@filmote , @Hanski also reported no sound in FemtoIDE. Same PokittoLib. We are investigating.


#36

Did you test with the volume set to maximum?


#37

In FemtoIDE and on the physical hardware … no sound!


#38

I’m going to do some more testing tonight, but I do get sound on hardware with PlayMusic when I set the volume to maximum.


#39

I’ve been porting my stochastic music toy from java to c++ and I have experienced very similar problems with sound. The PlaySFX example worked ok and also writing directly to Pokitto’s sound buffers, but with everything else (SFXeditor, PlayMusic, SynthTest) I got very faint sound on hardware and no sound at all on emulator.

I finally found a solution after testing different defines in My_settings.h file. Adding this line made the sound work:
#define PROJ_STREAM_TO_DAC 0

My_settings.h file:

#ifndef MY_SETTINGS_H
#define MY_SETTINGS_H

#define PROJ_HIRES 1            //1 = high resolution (220x176) , 0 = low resolution fast mode (110x88)

#define PROJ_ENABLE_SOUND 1     // 0 = all sound functions disabled
#define PROJ_ENABLE_SYNTH 1
#define PROJ_AUD_FREQ 22050

//#define PROJ_STREAMING_MUSIC 0
#define PROJ_STREAM_TO_DAC 0
//#define PROJ_USE_PWM 0

#endif