Hello!
So I'm trying to get it to where I can simply put in an SD card full of audio samples roughly around 4 beats, or 1 full measure. Before getting into all the craziness about how to scroll through all the tracks, or putting 1 sample of 1 measure playing alongside a sample that is 2 measures, right now i'm just trying to play one sample in a seamless loop. Having it play twice through 2 mixers and having the second playback of the same track a millisecond before the other one finishes isn't precise enough because various bpm's would require different lengths before the finish in order to make it a seamless loop playing 'in time' . Therefore I decided to try it as a RAW file and hope it'll just loop without having to parse the header first. That totally worked by the way! The problem? It is playing the raw file in a much slower BPM than it originally played. Any thoughts?
So I'm trying to get it to where I can simply put in an SD card full of audio samples roughly around 4 beats, or 1 full measure. Before getting into all the craziness about how to scroll through all the tracks, or putting 1 sample of 1 measure playing alongside a sample that is 2 measures, right now i'm just trying to play one sample in a seamless loop. Having it play twice through 2 mixers and having the second playback of the same track a millisecond before the other one finishes isn't precise enough because various bpm's would require different lengths before the finish in order to make it a seamless loop playing 'in time' . Therefore I decided to try it as a RAW file and hope it'll just loop without having to parse the header first. That totally worked by the way! The problem? It is playing the raw file in a much slower BPM than it originally played. Any thoughts?
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdRaw playSdRaw1; //xy=267,209
AudioOutputI2S i2s1; //xy=605,196
AudioConnection patchCord1(playSdRaw1, 0, i2s1, 0);
AudioConnection patchCord2(playSdRaw1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=457,320
#define SDCARD_CS_PIN 10
#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 (playSdRaw1.isPlaying() == false) {
Serial.println("Start playing");
playSdRaw1.play("DRUMRAW1.RAW");
delay(10); // wait for library to parse WAV info
}
}
Last edited by a moderator: