Hey all - pretty new to teensy environment. I have a 3.5 and the STGL5000 audio board and a 16GB sandisk ultra card.
I'm trying to loop a sample seamlessly. I have generated the sample in audacity, and modified the wav SD code example to operate with RAW. Initially, I used wav, but then figured the header might be the reason for the delay, so have now switched to RAW. However, the delay is still there. In audacity, the sample loops cleanly.
It sounds fine on the teensy, but with a short delay looping. How do I eliminate this? I found https://forum.pjrc.com/threads/43547-Seamless-Looping?highlight=seamless+loop which is fairly similar except that it was using wav files and a workaround of guessing when the file would finish and playing an identical one to start at the end time. Surely there must be a better solution?
Thank you for help
I'm trying to loop a sample seamlessly. I have generated the sample in audacity, and modified the wav SD code example to operate with RAW. Initially, I used wav, but then figured the header might be the reason for the delay, so have now switched to RAW. However, the delay is still there. In audacity, the sample loops cleanly.
It sounds fine on the teensy, but with a short delay looping. How do I eliminate this? I found https://forum.pjrc.com/threads/43547-Seamless-Looping?highlight=seamless+loop which is fairly similar except that it was using wav files and a workaround of guessing when the file would finish and playing an identical one to start at the end time. Surely there must be a better solution?
Thank you for help
Code:
// Advanced Microcontroller-based Audio Workshop
//
// http://www.pjrc.com/store/audio_tutorial_kit.html
// https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
//
// Part 1-3: First "Hello World" program, play a music file
//
// WAV files for this and other Tutorials are here:
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdRaw PlayRawe;
AudioOutputI2S i2s1;
AudioConnection patchCord1(PlayRawe, 0, i2s1, 0);
AudioConnection patchCord2(PlayRawe, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1;
// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
// Use these with the Teensy 3.5 & 3.6 SD card
//#define SDCARD_CS_PIN BUILTIN_SDCARD
//#define SDCARD_MOSI_PIN 11 // not actually used
//#define SDCARD_SCK_PIN 13 // not actually used
// Use these for the SD+Wiz820 or other adaptors
//#define SDCARD_CS_PIN 4
//#define SDCARD_MOSI_PIN 11
//#define SDCARD_SCK_PIN 13
void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
delay(1000);
}
void loop() {
if (PlayRawe.isPlaying() == false) {
// Serial.println("Start playing");
PlayRawe.play("SDTEST2.raw");
delay(10);
}
// do nothing while playing...
}