Teensy 3.2, prop shield LC, and sd card module, is it possible?

Status
Not open for further replies.

Andyroo89

New member
I have been googling, in any ways I can about teensy 3.2 prop shield and sd card, and is it not possible to play wav files from sd card when using prop shield + T3.2?

I would use an audio shield, but I don't need stereo output for my project, mono is perfectly fine, unless if I want to sd card I need to switch to a audio adapter.

Please let me know! thank you!
 
Before going down the route of trying to add both a micro-SD card reader and the prop-shield, if you don't need to remove the micro-SD card, but are just using it to store pre-recorded sounds/songs, and you don't need loads of space, both prop shields have an 8 megabyte flash memory storage area. This is the simplest approach. You would need to convert the files from WAV to RAW format (at the moment, the only method to play sounds from flash memory use the RAW format). I don't remember where the directions for converting WAV to RAW files are at the moment:

Code:
// Converted from the WavFilePlay from the Teensy release:
// hardware/teensy/avr/libraries/Audio/examples/WavFilePlayer/WavFilePlayer.ino
//
// Simple RAW file player example for the prop shield to use the Analog DAC
// and prop shield amplifier to play mono sounds.
//         http://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog
//
// On the prop shield, pin 6 selects the serial flash memory controller,
// and pin 5 enables the amplifier.
//
// This example code is in the public domain.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlaySerialflashRaw  playFlashRaw1;  //xy=149,388
AudioMixer4              mixer1;         //xy=445,386
AudioOutputAnalog        dac1;           //xy=591,379
AudioConnection          patchCord1(playFlashRaw1, 0, mixer1, 0);
AudioConnection          patchCord2(mixer1, dac1);
// GUItool: end automatically generated code

#define PROP_AMP_ENABLE		5
#define FLASH_CHIP_SELECT	6
#define VOLUME_POT		A1

void setup() {
  Serial.begin(9600);

  // wait up to 3 seconds for the Serial device to become available
  long unsigned debug_start = millis ();
  while (!Serial && ((millis () - debug_start) <= 3000))
    ;

  Serial.println ("Start prop shield RAW player");

  // Enable the amplifier on the prop shield
  pinMode(PROP_AMP_ENABLE, OUTPUT);
  digitalWrite(PROP_AMP_ENABLE, HIGH);

  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(8);

  // Set initial volume
  // mixer1.gain(0, 0.5f);

  // uncomment these lines if you have a potentiometer or trimpot
  // on the pin A1 to control the volume, and comment out the
  // above line
  float vol = analogRead(VOLUME_POT);
  mixer1.gain(0, vol / 1024.0f);

  // Start SerialFlash
  if (!SerialFlash.begin(FLASH_CHIP_SELECT)) {
    while (1)
      {
	Serial.println ("Cannot access SPI Flash chip");
	delay (1000);
      }
  }
}

void playFile(const char *filename)
{
  Serial.print("Playing file: ");
  Serial.println(filename);

  // Start playing the file.  This sketch continues to
  // run while the file plays.
  playFlashRaw1.play(filename);

  // A brief delay for the library read RAW info
  delay(5);

  // Simply wait for the file to finish playing.
  while (playFlashRaw1.isPlaying()) {
    // uncomment these lines if you have a potentiometer or trimpot
    // on the pin A1 to control the volume
    float vol = analogRead(VOLUME_POT);
    mixer1.gain(0, vol / 1024.0f);
  }
}


void loop() {
  playFile("SDTEST1.RAW");  // filenames are always uppercase 8.3 format
  delay(500);
  playFile("SDTEST2.RAW");
  delay(500);
  playFile("SDTEST3.RAW");
  delay(500);
  playFile("SDTEST4.RAW");
  delay(1500);
}

You can use TeensyTransfer to transfer files to/from the flash memory:

If you still want to use a micro-SD or full-size SD card, there are various options to attach it to the Teensy. But it might be simplest if you don't attach the micro-SD card, and just use the LC prop shield. But I can give you pointers if desired.
 
Thanks for the response, it just dawned on me that there is nothing hold me back from taking sound clips I want to use and convert them to RAW and see if I can fit all of them on the flash memory. quick calculator shows 6 second audio clip, mono, 44.1k, raw? 506kb, hmm sound about right?
 
Status
Not open for further replies.
Back
Top