wearyhacker
Well-known member
This question is related to my loading soundfonts from the sd card project discussed in this thread and and available on GitHub here.
The following is a snippet from my test sketch.
The problem is the sine wave plays fine, but nothing comes out when I try to play a frequency via the wavetable.
What am I missing?
The following is an edited trace of my logging.
No sound comes out.
What have I messed up?
What have I have I missed out?
Is this even possible?
All help gratefully received!
The following is a snippet from my test sketch.
C++:
Main audioObjects;
void setup()
{
while (!Serial);
Log.begin(LOG_LEVEL_VERBOSE, &Serial);
Log.verbose("Initialising audio memory\n");
AudioMemory(400);
Log.verbose("Disabling audio interrupts\n");
AudioNoInterrupts();
Log.verbose("Preparing to play a sine wave\n");
audioObjects.mixer.gain(0, 1.0);
audioObjects.mixer.gain(1, 0.0);
audioObjects.mixer1.gain(0, 1.0);
audioObjects.mixer1.gain(1, 0.0);
audioObjects.sine.amplitude(1.0);
audioObjects.sine.frequency(440.0);
Log.verbose("Enabling audio interrupts\n");
AudioInterrupts();
Log.verbose("Playing a sine wave for 2 seconds\n");
delay(2000);
Log.verbose("Disabling audio interrupts\n");
AudioNoInterrupts();
Log.verbose("Attempting to load the test data\n");
AudioSynthWavetable::instrument_data* new_instrument = CInstrument::getInstance()->load("test.bin");
if (nullptr == new_instrument)
Log.verbose("Failed to load test data\n");
else
{
audioObjects.wavetable.setInstrument(*new_instrument);
}
audioObjects.mixer.gain(0, 0.0);
audioObjects.mixer.gain(1, 1.0);
audioObjects.mixer1.gain(0, 0.0);
audioObjects.mixer1.gain(1, 1.0);
audioObjects.wavetable.amplitude(1.0);
Log.verbose("Enabling audio interrupts\n");
AudioInterrupts();
}
void loop()
{
static bool first_time = true;
if (first_time)
{
first_time = false;
Log.verbose("Playing a note for ten seconds\n");
audioObjects.wavetable.playFrequency(880.0);
delay(10000);
Log.verbose("Stopping the note\n");
audioObjects.wavetable.stop();
}
else
delay(1000);
}
The problem is the sine wave plays fine, but nothing comes out when I try to play a frequency via the wavetable.
What am I missing?
The following is an edited trace of my logging.
Code:
* Executing task in folder platformio: platformio device monitor --environment sf2bin
--- Terminal on /dev/ttyACM0 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
V: Initialising audio memory
V: Disabling audio interrupts
The following section works.
V: Preparing to play a sine wave
V: Enabling audio interrupts
V: Playing a sine wave for 2 seconds
V: Disabling audio interrupts
This bit loads the binary image of the instrument data from the sd card. It appears to work
V: Attempting to load the test data
V: Line 158 Opening file test.bin
V: Line 167 sizeof(uint8_t) 1 sizeof instrument_data.sample_count 1
V: Line 174 Number of samples 4
V: Line 176 file position before reading raw sample sizes 1
V: Line 186 raw_sample_sizes 8
V: Line 194 raw_sample_sizes data 2021c9d8
V: Line 205 file position before reading sample note ranges 9
V: Line 209 sample_note_ranges_array_size 4
V: Line 223 sample_note_ranges_array address 2021c9e8
V: Line 249 samples_metadata_array address 2021c9f8
V: Line 253 file position before reading sample metadata array 13
V: Line 29 bytes 2021C9F8 count 96 index 96
This is a dump of sample metadata 0
V: Line 36 row 2021c9f8 ef be ad de 00 00 00 00
V: Line 36 row 2021ca00 01 0c 00 00 00 ae c0 72
V: Line 36 row 2021ca08 44 00 00 20 a0 00 00 10
V: Line 36 row 2021ca10 a0 00 00 00 33 ff ff 00
V: Line 36 row 2021ca18 00 00 00 06 00 00 00 00
V: Line 36 row 2021ca20 00 00 00 06 00 00 00 06
V: Line 36 row 2021ca28 00 00 00 00 00 00 00 00
V: Line 36 row 2021ca30 00 00 00 55 f2 85 01 00
V: Line 36 row 2021ca38 00 00 00 00 00 00 00 00
V: Line 36 row 2021ca40 00 00 00 55 f2 85 01 00
V: Line 36 row 2021ca48 00 00 00 00 00 00 00 00
V: Line 36 row 2021ca50 00 00 00 00 00 00 00 00
V: Line 273 samples_metadata_array[0].sample before fixup deadbeef
V: Line 274 samples_metadata_array[0].number_of_raw_samples 1408
V: Line 289 file position before reading raw sample data 397
V: Line 290 sample 0 metadata
V: Line 292 samples_metadata_array[0].sample after fixup 2021cd58
V: Line 293 samples_metadata_array[0].number_of_raw_samples 1408
V: Line 304 sample 0 data
V: Line 57 bytes 2021CD58 count 1408 index 1408
V: Line 64 row 2021cd58 fb48f9b3 fdd8fbdb 0123001b 032201eb 03aa02eb 08bc0678 099508c5 04150661
Lots of lines removed.
V: Line 64 row 2021e338 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
V: Line 29 bytes 2021CA58 count 96 index 96
This is a dump of sample metadata 1
V: Line 36 row 2021ca58 ef be ad de 00 00 00 00
V: Line 36 row 2021ca60 01 0a 00 00 00 0c 8f 00
V: Line 36 row 2021ca68 45 00 00 00 be 00 00 c0
V: Line 36 row 2021ca70 bd 00 00 c0 30 ff ff 00
V: Line 36 row 2021ca78 00 00 00 06 00 00 00 00
V: Line 36 row 2021ca80 00 00 00 06 00 00 00 06
V: Line 36 row 2021ca88 00 00 00 00 00 00 00 00
V: Line 36 row 2021ca90 00 00 00 55 f2 85 01 00
V: Line 36 row 2021ca98 00 00 00 00 00 00 00 00
V: Line 36 row 2021caa0 00 00 00 55 f2 85 01 00
V: Line 36 row 2021caa8 00 00 00 00 00 00 00 00
V: Line 36 row 2021cab0 00 00 00 00 00 00 00 00
V: Line 273 samples_metadata_array[1].sample before fixup deadbeef
V: Line 274 samples_metadata_array[1].number_of_raw_samples 384
V: Line 289 file position before reading raw sample data 6029
V: Line 290 sample 1 metadata
V: Line 292 samples_metadata_array[1].sample after fixup 2021e3b8
V: Line 293 samples_metadata_array[1].number_of_raw_samples 384
V: Line 304 sample 1 data
V: Line 57 bytes 2021E3B8 count 384 index 384
V: Line 64 row 2021e3b8 fe570065 004afe77 003cff0b ff960059 01bb0056 02100240 03710374 08980569
Lots of lines removed.
V: Line 64 row 2021e998 30992166 eba24c92 ecdb9c4e 1dbfece5 ebf47136 00000000 00000000 00000000
V: Line 29 bytes 2021CAB8 count 96 index 96
This is a dump of sample metadata 2
V: Line 36 row 2021cab8 ef be ad de 00 00 00 00
V: Line 36 row 2021cac0 01 0a 00 00 00 0c 97 80
V: Line 36 row 2021cac8 44 00 00 00 d1 00 00 c0
V: Line 36 row 2021cad0 d0 00 00 00 49 ff ff 00
V: Line 36 row 2021cad8 00 00 00 06 00 00 00 00
V: Line 36 row 2021cae0 00 00 00 06 00 00 00 06
V: Line 36 row 2021cae8 00 00 00 00 00 00 00 00
V: Line 36 row 2021caf0 00 00 00 55 f2 85 01 00
V: Line 36 row 2021caf8 00 00 00 00 00 00 00 00
V: Line 36 row 2021cb00 00 00 00 55 f2 85 01 00
V: Line 36 row 2021cb08 00 00 00 00 00 00 00 00
V: Line 36 row 2021cb10 00 00 00 00 00 00 00 00
V: Line 273 samples_metadata_array[2].sample before fixup deadbeef
V: Line 274 samples_metadata_array[2].number_of_raw_samples 512
V: Line 289 file position before reading raw sample data 7565
V: Line 290 sample 2 metadata
V: Line 292 samples_metadata_array[2].sample after fixup 2021e9c0
V: Line 293 samples_metadata_array[2].number_of_raw_samples 512
V: Line 304 sample 2 data
V: Line 57 bytes 2021E9C0 count 512 index 512
V: Line 64 row 2021e9c0 02ce0477 ff80011d fb9bfdc1 fb53fcbe 02e6fe6b 05010108 010702a1 fdf300ad
Lots of lines removed.
V: Line 64 row 2021f1a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
V: Line 29 bytes 2021CB18 count 96 index 96
This is a dump of sample metadata 3
V: Line 36 row 2021cb18 ef be ad de 00 00 00 00
V: Line 36 row 2021cb20 01 09 00 00 00 0c 97 80
V: Line 36 row 2021cb28 44 00 00 80 e5 00 00 00
V: Line 36 row 2021cb30 e5 00 00 00 2e ff ff 00
V: Line 36 row 2021cb38 00 00 00 06 00 00 00 00
V: Line 36 row 2021cb40 00 00 00 06 00 00 00 06
V: Line 36 row 2021cb48 00 00 00 00 00 00 00 00
V: Line 36 row 2021cb50 00 00 00 55 f2 85 01 00
V: Line 36 row 2021cb58 00 00 00 00 00 00 00 00
V: Line 36 row 2021cb60 00 00 00 55 f2 85 01 00
V: Line 36 row 2021cb68 00 00 00 00 00 00 00 00
V: Line 36 row 2021cb70 00 00 00 00 00 00 00 00
V: Line 273 samples_metadata_array[3].sample before fixup deadbeef
V: Line 274 samples_metadata_array[3].number_of_raw_samples 256
V: Line 289 file position before reading raw sample data 9613
V: Line 290 sample 3 metadata
V: Line 292 samples_metadata_array[3].sample after fixup 2021f1c8
V: Line 293 samples_metadata_array[3].number_of_raw_samples 256
V: Line 304 sample 3 data
V: Line 57 bytes 2021F1C8 count 256 index 256
V: Line 64 row 2021f1c8 ff69fcf4 0051fec1 ff3cfe69 fea1fdb7 028601b9 fac7ff3d 0498fecb 034e032b
Lots of lines removed.
V: Line 64 row 2021f5a8 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
V: Instrument data
===============
Number of samples 4
Sample note ranges pointer 0x2021c9e8
V: Enabling audio interrupts
V: Playing a note for ten seconds
V: current_sample 2021c9f8 tone_phase 0 tone_incr -1 tone_amp 46294
env_state 1 env_count 100663296 env_mult 0 env_incr 0
vib_count 0 vib_phase c0000000 vib_pitch_offset_init 0 vib_pitch_offset_scnd 0
mod_count 0 mod_phase c0000000 mod_pitch_offset_init 0 mod_pitch_offset_scnd 0
All of the stuff above appears correct.
The following diagnostics are from AudioSynthWavetable::update
V: About to allocate block
V: About to start loop
V: top of loop
V: Got to 1
V: Got to 2
V: Got to 3
V: Got to 4
V: top of loop
V: Got to 8
V: Got to 9
V: Got to 11
V: Got to 12
V: Stopping the note
No sound comes out.
What have I messed up?
What have I have I missed out?
Is this even possible?
All help gratefully received!