It is necessary in my code to load the samples into RAM.I removed the vocoder code and tried loading the RAM & play sample, the same files loaded very quickly in just 1 second and start play. Simple code without vocoder is as follow:
I'll try to slowly mix the more vocoder code into this sketch.
in
After mixing more control code I will report what I got......
Thank you.............
C++:
#include <Audio.h> // WAV playing will
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include "effect_phaseVocoder.h"
AudioEffectPhaseVocoder vocoder;
AudioOutputI2S audioOut;
AudioControlSGTL5000 codec;
AudioConnection patchLeft (vocoder, 0, audioOut, 0);
AudioConnection patchRight(vocoder, 0, audioOut, 1);
// RAM CODE
#define NUM_WAVS 16 // avoid silly mistakes
const char *SMP_WAV[NUM_WAVS] = { "A01.WAV", "A02.WAV", "A03.WAV", "A04.WAV", "05.WAV", "06.WAV", "07.WAV", "08.WAV", "09.WAV", "10.WAV", "11.WAV", "12.WAV", "13.WAV", "14.WAV", "15.WAV", "16.WAV" };
File x_File;
int16_t *SMP_addr[NUM_WAVS];
uint32_t sizes[NUM_WAVS];
void setup() {
AudioMemory(40);
Serial.begin(57600);
codec.enable();
codec.volume(0.5f);
if (!SD.begin(BUILTIN_SDCARD)) {
Serial.println("SD init failed");
return;
}
Serial.println("Card ok");
RAM_LOAD (); Serial.println("RAM loaded........................");
vocoder.stop();
vocoder.setSample(SMP_addr[0], sizes[0]/2);
vocoder.setLoop(true);
// applyStretch(stretch);
vocoder.play();
}
void loop() {
}
///=========================================
void RAM_LOAD () {
int SMP_FILE_NUM=0;
for (int i = 0; i < NUM_WAVS; i++) {
x_File = SD.open(SMP_WAV[i], FILE_READ);
if (x_File)
{
sizes[i] = x_File.size();
SMP_addr[i] = (int16_t*) extmem_malloc(sizes[i]);
if (nullptr == SMP_addr[i])
Serial.printf("Failed to allocate %d in EXTMEM for %s\n", sizes[i], SMP_WAV[i]);
else {
if (sizes[i] != x_File.read(SMP_addr[i], sizes[i]))
{
Serial.printf("Failed to read in %s - wrong length\n", SMP_WAV[i]);
extmem_free(SMP_addr[i]); // free memory
SMP_addr[i] = nullptr; // mark as "not loaded"
}
else
Serial.printf("Read %s into memory at %08X; %d bytes\n", SMP_WAV[i], SMP_addr[i], sizes[i]);
}
x_File.close();
}
else
Serial.printf("Failed to open %s\n", SMP_WAV[i]);
}
}
in
vocoder.setSample(SMP_addr[3], sizes[3] / 2); i used sizes[3] / 2) only for complete duration of my drum loop.If I don't do this, then in loop mode, half the sequence plays with the SMP_addr[3] and the other half plays with some other sample. when i use vocoder.setSample(SMP_addr[3], sizes[3] / 2); Selected samples play well with complete duration.After mixing more control code I will report what I got......
Thank you.............
Last edited: