RAW headerless file playing at a super slow BPM

Status
Not open for further replies.

NewtonBIV

Active member
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?

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:
Might be a problem with your raw file.
It must be 44100Hz, 16 Bit, two channel (stereo).

Well Frank, I was (with full on smug self satisfaction btw) about to comment on here rather pompously that of course I had exported the file under these specs. In fact, just to ensure no one might second guess me I decided to export another one of the samples just to make sure in the bright lights that I was indeed doing it right. Then for some reason I tried that file and.......it totally worked!!!!!

I'm not going to even question it, I swear the first file I did was 44100Hz, 16 big (signed PCM) and 2 channel stereo as well as little endian, but for some reason that first file plays at like half time. the second file I did again worked perfectly though and sure enough, looping is entirely seamless and it will be seamless surely no matter how long the file is too so there won't be need for any weird math algorithms to determine how much before the end of the first clip I should be starting the second one. I'm this much closer to my Commuter Groove Box. Thank you Frank B you totally saved the freaking day!
 
Status
Not open for further replies.
Back
Top