Browse Source

Rename AudioPlaySDcardWAV to AudioPlaySdWav

dds
PaulStoffregen 10 years ago
parent
commit
5ff60b9a70
3 changed files with 12 additions and 12 deletions
  1. +1
    -1
      examples/PlayWavFromSdCard/PlayWavFromSdCard.ino
  2. +9
    -9
      play_sd_wav.cpp
  3. +2
    -2
      play_sd_wav.h

+ 1
- 1
examples/PlayWavFromSdCard/PlayWavFromSdCard.ino View File

// Create the Audio components. These should be created in the // Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs // order data flows, inputs/sources -> processing -> outputs
// //
AudioPlaySDcardWAV wav;
AudioPlaySdWav wav;
AudioOutputI2S dac; AudioOutputI2S dac;


// Create Audio connections between the components // Create Audio connections between the components

+ 9
- 9
play_sd_wav.cpp View File

#define STATE_PARSE4 11 // ignoring unknown chunk #define STATE_PARSE4 11 // ignoring unknown chunk
#define STATE_STOP 12 #define STATE_STOP 12


void AudioPlaySDcardWAV::begin(void)
void AudioPlaySdWav::begin(void)
{ {
state = STATE_STOP; state = STATE_STOP;
state_play = STATE_STOP; state_play = STATE_STOP;
} }




bool AudioPlaySDcardWAV::play(const char *filename)
bool AudioPlaySdWav::play(const char *filename)
{ {
stop(); stop();
wavfile = SD.open(filename); wavfile = SD.open(filename);
return true; return true;
} }


void AudioPlaySDcardWAV::stop(void)
void AudioPlaySdWav::stop(void)
{ {
__disable_irq(); __disable_irq();
if (state != STATE_STOP) { if (state != STATE_STOP) {
} }
} }


bool AudioPlaySDcardWAV::start(void)
bool AudioPlaySdWav::start(void)
{ {
__disable_irq(); __disable_irq();
if (state == STATE_STOP) { if (state == STATE_STOP) {
} }




void AudioPlaySDcardWAV::update(void)
void AudioPlaySdWav::update(void)
{ {
// only update if we're playing // only update if we're playing
if (state == STATE_STOP) return; if (state == STATE_STOP) return;
// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/


// Consume already buffered data. Returns true if audio transmitted. // Consume already buffered data. Returns true if audio transmitted.
bool AudioPlaySDcardWAV::consume(void)
bool AudioPlaySdWav::consume(void)
{ {
uint32_t len, size; uint32_t len, size;
uint8_t lsb, msb; uint8_t lsb, msb;
p = buffer + 512 - size; p = buffer + 512 - size;
start: start:
if (size == 0) return false; if (size == 0) return false;
//Serial.print("AudioPlaySDcardWAV write, size = ");
//Serial.print("AudioPlaySdWav write, size = ");
//Serial.print(size); //Serial.print(size);
//Serial.print(", data_length = "); //Serial.print(", data_length = ");
//Serial.print(data_length); //Serial.print(data_length);


// this is not supposed to happen! // this is not supposed to happen!
//default: //default:
//Serial.println("AudioPlaySDcardWAV, unknown state");
//Serial.println("AudioPlaySdWav, unknown state");
} }
state_play = STATE_STOP; state_play = STATE_STOP;
state = STATE_STOP; state = STATE_STOP;






bool AudioPlaySDcardWAV::parse_format(void)
bool AudioPlaySdWav::parse_format(void)
{ {
uint8_t num = 0; uint8_t num = 0;
uint16_t format; uint16_t format;

+ 2
- 2
play_sd_wav.h View File

#include "AudioStream.h" #include "AudioStream.h"
#include "SD.h" #include "SD.h"


class AudioPlaySDcardWAV : public AudioStream
class AudioPlaySdWav : public AudioStream
{ {
public: public:
AudioPlaySDcardWAV(void) : AudioStream(0, NULL) { begin(); }
AudioPlaySdWav(void) : AudioStream(0, NULL) { begin(); }
void begin(void); void begin(void);


bool play(const char *filename); bool play(const char *filename);

Loading…
Cancel
Save