Stompbox Looper - Which Teensy

Status
Not open for further replies.

sethhead

Member
Hi there,

I have some experience with using a Teensy 3.2 and the audio shield, however I had issues with crashing that I am chalking up to a problem with the Teensy 3.2, see my previous post here (Advice on troubleshooting this project is still welcome).

Anyways, I am currently trying to start a new project that would essentially be a stompbox pedal for making a simple looper that would record sound and play it back continuously with the option to overdub over the original recording. I am fairly confident I can code this using the audio library, however I am wanting to avoid similar hardware problems that I encountered in my last project. I am considering using a Raspberry Pi because of this, however what I am trying to do is simple enough that I would love to use a Teensy since I am already knowledgeable on a lot of the libraries and would like to save some space in the enclosure.

Does anyone know if there's a model of the Teensy that is more stable than the Teensy 3.2 + audio shield for what I am trying to do?
 
Accessing the SD card from your main program while the audio library is also using from interrupts to play sounds, without using AudioNoInterrupts() to keep the audio library from running while you use the card, is likely to crash on any Teensy.

If you go back to that Teensy 3.2 project, add AudioNoInterrupts() and AudioInterrupts() around the places where your program accesses the SD card while the audio library might also be trying to use it. Detailed documentation here:

https://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html

If you start a new project and write all new code, maybe consider ways of getting all the info you will need from the card before you begin playing sounds.
 
Accessing the SD card from your main program while the audio library is also using from interrupts to play sounds, without using AudioNoInterrupts() to keep the audio library from running while you use the card, is likely to crash on any Teensy.

If you go back to that Teensy 3.2 project, add AudioNoInterrupts() and AudioInterrupts() around the places where your program accesses the SD card while the audio library might also be trying to use it. Detailed documentation here:

https://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html

Would you possibly be able to show me an example of when the audio library and my program are accessing the SD card at the same time? I can't seem to find that happening in my code (specifically the simplified test version with hard coded file locations).

Code:
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <string.h>

//documentation for these libraries are found here: https://www.pjrc.com/teensy/gui/?info=AudioPlaySdWav

AudioPlaySdWav           playSdWav2;     //xy=291,430
AudioPlaySdWav           playSdWav1;     //xy=296,301
AudioMixer4              mixer1;         //xy=563,363
AudioOutputI2S           i2s1;           //xy=780,362
AudioConnection          patchCord1(playSdWav2, 0, mixer1, 1);
AudioConnection          patchCord2(playSdWav1, 0, mixer1, 0);
AudioConnection          patchCord3(mixer1, 0, i2s1, 0);
AudioConnection          patchCord4(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=64.5,50

// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14

//int buttonPins[] = {0,1,2,3,4,5,8,15,16,17,20,21};

Bounce buttonA = Bounce(0, 10);
Bounce buttonB = Bounce(1, 10);
Bounce buttonY = Bounce(2, 10);
Bounce buttonX = Bounce(3, 10);
Bounce buttonR = Bounce(4, 10);
Bounce buttonL = Bounce(5, 10);
Bounce buttonStart = Bounce(8, 10);
Bounce buttonUp = Bounce(15, 10);
Bounce buttonRight = Bounce(16, 10);
Bounce buttonDown = Bounce(17, 10);
Bounce buttonLeft = Bounce(20, 10);
Bounce buttonSelect = Bounce(21, 10);


void setup() {


  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(15, INPUT_PULLUP);
  pinMode(16, INPUT_PULLUP);
  pinMode(17, INPUT_PULLUP);
  pinMode(20, INPUT_PULLUP);
  pinMode(21, INPUT_PULLUP);

  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);
  }
  delay(1000);   
}

void loop() {
  //what to do for each button press
  if (buttonA.update()){
    if (buttonA.fallingEdge()){
      playSdWav1.play("_GAMES/_megman/a.WAV");
    }
  };
  if (buttonStart.update()){
    if (buttonStart.fallingEdge()){
      playSdWav2.play("_GAMES/_megman/bgr/airman.WAV");
    }
  };
}

I know this should probably be in the other thread at this point, but I feel like understanding this problem is pivotal for me to be able to start a new project that would potentially have the same issues.
 
Status
Not open for further replies.
Back
Top