Skip to content

Commit

Permalink
Fix audio-wave example sample rate (#149)
Browse files Browse the repository at this point in the history
* Fix audio-wave example:
- Sample was 22050, not 11025.
- Sustain not required - already defaults to this value.
  • Loading branch information
tinwhisker authored Feb 14, 2020
1 parent fbd89f0 commit 3e7bd73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions examples/audio-wave/audio-wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
This example, a runthrough:
Audio data:
The audio file has been converted to 11025Hz sample rate, then exported as 16bit PCM, but without its header.
The audio file has been converted to 22050Hz sample rate, then exported without its header.
(If a headered file is used, just read past that first. Try skipping the first 44 bytes).
You would preferably store files separate because uncompressed audio will use all your flash!
Here though, the raw wave to a c header using 'xxd -i glass.raw glass.h'
Expand All @@ -38,8 +38,7 @@ void buffCallBack(void *); //Declare our callback here instead of putting the
void init() {

// Setup channel
channels[0].waveforms = Waveform::WAVE; // Set type to WAVE
channels[0].sustain = 0xffff; // Set sustain to max
channels[0].waveforms = Waveform::WAVE; // Set type to WAVE
channels[0].callback_waveBufferRefresh = &buffCallBack; // Set callback address

screen.pen = Pen(0, 0, 0, 255);
Expand Down Expand Up @@ -97,11 +96,10 @@ void render(uint32_t time_ms) {


bool button_a = blit::buttons & blit::Button::A;

// If 'A' button pushed
if(button_a){
wavSample = glass_wav; // Set sample to the array in glass.h
wavSampleRate = 11025; // Note the sample rate
wavSize = glass_wav_len; // Set the array length to the value in glass.h
channels[0].trigger_attack(); // Start the playback.
}
Expand Down
1 change: 0 additions & 1 deletion examples/audio-wave/glass_u8.raw

This file was deleted.

0 comments on commit 3e7bd73

Please sign in to comment.