-
Notifications
You must be signed in to change notification settings - Fork 43
Soundfont.h
Soundfont.h is the place you can configure your sound fonts used wrt:
- how many sound fonts you have
- what is the structure of your sound fonts, i.e. how many of each type of sound you have and in which order
Why is it important to define the structure? The answer is easy: the MP3/Wav codec chip used in this project only cares about the physical order of sounds on the storage media (SD-card for DIYino Prime v1 and home-brew solutions and SPI-Flash for the Stardust v2). This means the code needs to be able to translate sound types to a number corresponding to the physical location of that sound file on the storage media. (Note that although for convenience's sake you can order your sound fonts and config sounds in folders, the codec chip will use a flat structure to determine the order of the files)
Now let's see how you can define the structure of your sound files. There are global defines to define the basic characteristics of your sould file storage structure:
- How many sound fonts you have is define by this parameter:
#define SOUNDFONT_QUANTITY 5
- There is a folder storing configuration sounds needed for the code, if in doubt simply look into that folder and see to it that it matches the definition here:
#define NR_CONFIGFOLDERFILES 29
- If you use the in-build MP3 player option, you can define how many songs you store in the JukeBox folder
#define NR_JUKEBOXSONGS 0
- A very important parameter which defines how many sound files you have in each of the sound fonts. It also means that all sound font folders must have the exact same number of files in the same order wrt sound types (swing, clash etc.)
#define NR_FILE_SF 30
Once the basic defines are settled, you can go on to define the structure of your sound font (as mentioned all sound fonts must follow the same structure). You can do it here:
#define SF_BOOT_OFFSET 1
#define SF_POWERON_OFFSET 2
#define SF_POWEROFF_OFFSET 6
#define SF_SWING_OFFSET 8
#define SF_CLASH_OFFSET 16
#define SF_LOCKUP_OFFSET 24
#define SF_BLASTER_OFFSET 25
#define SF_MENU_OFFSET 29
#define SF_HUM_OFFSET 30
#define SF_BOOT_NR 1
#define SF_POWERON_NR 4
#define SF_POWEROFF_NR 2
#define SF_SWING_NR 8
#define SF_CLASH_NR 8
#define SF_LOCKUP_NR 1
#define SF_BLASTER_NR 4
#define SF_MENU_NR 1
#define SF_HUM_NR 1
Each of the sound types have 2 parameters:
- Offset which defines where a particular sound type begins in one sound font folder, in the example below the first clash sound file is the 16th file in the folder, preceded by 1(boot)+4(power-on)+2(power-off)+8(swings)=15 other sound files. Therefore the offset for the clash sounds is 16.
#define SF_CLASH_OFFSET 16
2. Nr of sound files for a certain sound type, for example if you want to have 8 clash sound, you define here 8.
#define SF_CLASH_NR 8
Now let's see an example how to change the structure to suit your preference. Let's assume you want to have only 2 blaster deflect sound.
First you change the number of files from 4 to 2:
#define SF_BLASTER_NR 4
-> #define SF_BLASTER_NR 2
Then you change the offsets to match your new structure:
#define SF_BLASTER_OFFSET 25
-> can stay unchanged since you do not touch the sequence before.
#define SF_MENU_OFFSET 29
-> #define SF_MENU_OFFSET 27
as there are 2 less blaster deflect sounds.
#define SF_HUM_OFFSET 30
-> #define SF_HUM_OFFSET 28
As with this change also the overall number of files in one sound font changes, you need to also change the global define like this:
#define NR_FILE_SF 30
-> #define NR_FILE_SF 28
to reflect that you now have only 28 files per sound font.
Another important parameter you can define in the Soundfont.h file is the duration of the ingitions and retractions (power-on and power-off sequences). Why is it important or necessary at all to define? Power-on and off sound fonts are always a bit longer than the actual ignition/retraction sound, therefore if you want your ignition/retraction to match the time of the corresponding sound, you need to define these durations. Since each sound font can have different durations, there are 2 parameters for each sound font (
case 0: // soundFont directory 01 : this->powerOnTime = 800; this->powerOffTime = 800; break;
The unit is ms (milliseconds).