Hi paul and all,
I'm trying to use the Teensy audio board as an organ keyboard with soundbanks, using teh 16GB SAN DISK.
Th board is running perfectly, when I'musing the waveplayer example.
But when I try to play a sound, when receiving MIDI ON from an external keyboard, there is no output sound, and no serial output.
Thanks for your help !
Source code below,
Pascal Leray
// Simple WAV file player example
//
// Requires the audio shield:
// http://www.pjrc.com/store/teensy3_audio.html
//
// Data files to put on your SD card can be downloaded here:
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
//
// This example code is in the public domain.
#include <MIDI.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <stdio.h>
#include <string.h>
char filenames[56][16]={"036-C.wav","037-C#.wav","038-D.wav","039-D#.wav"};
// GUItool: begin automatically generated code
AudioPlaySdWav playWav1; //xy=154,78
AudioOutputI2S i2s1; //xy=334,89
AudioConnection patchCord1(playWav1, 0, i2s1, 0);
AudioConnection patchCord2(playWav1, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=240,153
// GUItool: end automatically generated code
void setup()
{
Serial.begin(9600);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(5);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(7);
SPI.setSCK(14);
Serial.print("BEGINNING");
if (!(SD.begin(10)))
{
// stop here, but print a message repetitively
while (1)
{
Serial.println("Unable to access the SD card");
delay(500);
}
}
}
void OnNoteOn(byte channel, byte note, byte velocity)
{
Serial.print("Note On, ch=");
Serial.print(note, DEC);
playFile(&filenames[note-36][0]);
}
void OnNoteOff(byte channel, byte note, byte velocity)
{
}
void playFile(const char *filename)
{
// Start playing the file. This sketch continues to
// run while the file plays.
playWav1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
/* while (playWav1.isPlaying())
{
// uncomment these lines if you audio shield
// has the optional volume pot soldered
//float vol = analogRead(15);
//vol = vol / 1024;
// sgtl5000_1.volume(vol);
}
*/
}
void loop()
{
usbMIDI.read();
}
I'm trying to use the Teensy audio board as an organ keyboard with soundbanks, using teh 16GB SAN DISK.
Th board is running perfectly, when I'musing the waveplayer example.
But when I try to play a sound, when receiving MIDI ON from an external keyboard, there is no output sound, and no serial output.
Thanks for your help !
Source code below,
Pascal Leray
// Simple WAV file player example
//
// Requires the audio shield:
// http://www.pjrc.com/store/teensy3_audio.html
//
// Data files to put on your SD card can be downloaded here:
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
//
// This example code is in the public domain.
#include <MIDI.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <stdio.h>
#include <string.h>
char filenames[56][16]={"036-C.wav","037-C#.wav","038-D.wav","039-D#.wav"};
// GUItool: begin automatically generated code
AudioPlaySdWav playWav1; //xy=154,78
AudioOutputI2S i2s1; //xy=334,89
AudioConnection patchCord1(playWav1, 0, i2s1, 0);
AudioConnection patchCord2(playWav1, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=240,153
// GUItool: end automatically generated code
void setup()
{
Serial.begin(9600);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(5);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(7);
SPI.setSCK(14);
Serial.print("BEGINNING");
if (!(SD.begin(10)))
{
// stop here, but print a message repetitively
while (1)
{
Serial.println("Unable to access the SD card");
delay(500);
}
}
}
void OnNoteOn(byte channel, byte note, byte velocity)
{
Serial.print("Note On, ch=");
Serial.print(note, DEC);
playFile(&filenames[note-36][0]);
}
void OnNoteOff(byte channel, byte note, byte velocity)
{
}
void playFile(const char *filename)
{
// Start playing the file. This sketch continues to
// run while the file plays.
playWav1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
/* while (playWav1.isPlaying())
{
// uncomment these lines if you audio shield
// has the optional volume pot soldered
//float vol = analogRead(15);
//vol = vol / 1024;
// sgtl5000_1.volume(vol);
}
*/
}
void loop()
{
usbMIDI.read();
}