Hi all,
I'm writing a simple audio object but something weird is happening...
I need to store audio blocks in my object, thus I am doing something really similar to the effect_delay object.
I've done this before and everything worked fine, but today something's wrong: as far as I try to acquire the input buffer pointer into my private audio_block_t * the audio output is muted (and the Teensy freezes) - see the comment in the code.
The code:
Any help appreciated... thanks!
I'm writing a simple audio object but something weird is happening...
I need to store audio blocks in my object, thus I am doing something really similar to the effect_delay object.
I've done this before and everything worked fine, but today something's wrong: as far as I try to acquire the input buffer pointer into my private audio_block_t * the audio output is muted (and the Teensy freezes) - see the comment in the code.
The code:
Code:
///////////////////////////////////////////////////////////////////////////////
// header:
#include "AudioStream.h"
#include "utility/dspinst.h"
#define NUM_MEMORY_BLOCKS 100
class MyModule : public AudioStream
{
public:
MyModule() : AudioStream( 1, mInputQueueArray )
{
memset( mpbuf, 0, sizeof(mpbuf) );
}
virtual void update(void);
private:
audio_block_t *mpbuf[1];
audio_block_t *mInputQueueArray[1];
};
///////////////////////////////////////////////////////////////////////////////
// cpp:
#include <Arduino.h>
#include <MyModule.h>
void MyModule::update(void)
{
audio_block_t *blockin;
// As far as I comment the line below, everything works fine ( I've tried also with receiveReadOnly() )
if ( !( mpbuf[0] = receiveWritable() ) ) return;
if ( mpbuf[0] != NULL ) release( mpbuf[0]);
mpbuf[0] = NULL;
if ( !( blockin = receiveWritable() ) ) return;
transmit( blockin );
release( blockin );
}
///////////////////////////////////////////////////////////////////////////////
/// .ino
#include "Arduino.h"
#include <Audio.h>
#include "MyModule.h"
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
MyModule module;
AudioControlSGTL5000 sgtl5000_1;
AudioInputI2S input;
AudioOutputI2S output;
AudioConnection patchCord1(input, 0, module, 0);
AudioConnection patchCord3(module, 0, output, 0);
void setup()
{
AudioMemory(NUM_MEMORY_BLOCKS);
sgtl5000_1.enable();
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
sgtl5000_1.volume(1);
}
void loop()
{
}
Any help appreciated... thanks!