Hello from a complete new guy to the world of Arduino/Teensy controllers. Just bought a Teensy 4.1 along with the audio shield board. Now I just need to wait for them to be delivered.
Anyhow, while I may be new to controllers I'm not new to electronics. For 35 years I've worked as a component level analog/digital electronics repair tech. Nine years of which was in the U.S. Air Force maintaining/repairing specialized equipment used to monitor nuclear weapons testing around the world. I've also got a background in programming. Was trained in COBOL (back in the 80's though), UNIX system admin (back when Solaris/Sparc 5's were around in the mid 90's), and my current job has me operating a Linux based test station.
Okay, enough of the unrelated chit chat. On to what brings me here and why I bought the Teensy 4.1. What I am trying to achieve is a control setup that will operate 4 independent stepper motors (little guys salvaged from CDROM drives that have the long drive screw for the read/write head) and each stepper motor will have a different sound file associated with it. While I think I understand what's needed for the stepper motor control (I'll have questions about that some other time) I'm currently trying to understand what my options are in regards to playing 4 RAW sound files at once. The sound files will be starting at different times so I can't merge them in to a single mp3 file. I watched the audio tutorial and saw how it showed 2 stereo mp3 files from an SD card being played simultaneously and 4 sample sounds being played at once. Using the Audio System Design Tool one option I'm looking at is something like the image below. It has 4 mono RAW sound files that are stored on the SD card. Two sound files need to be mixed together for the left speaker and the other 2 mixed together and routed to the right speaker. While this is more of a generic question and not about scripting (sketch) I've added the sketch text that the design tool provided at the end of my post just in case.
Since the overall output is still the standard stereo output of the audio card is this doable? If not would adding a W25Q128FV Serial Flash chip and storing the 4 sound RAW files on the flash memory by using playFlashRaw instead of playSDRaw? Here's what the design tool says about the playFlashRaw option.
Summary: Play a RAW data file, stored on a Serial Flash chip. These chips are far more efficient than SD cards, allowing many files to be played simultaneously by copies of this object.
I hope I've crossed all the i's and dotted all the required t's with my first post. I hope to learn more as this project progresses and I buy addition modules. Thanks in advance for any help that is provided towards completion of this project.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdRaw playSdRaw2; //xy=510.33331298828125,264.3333435058594
AudioPlaySdRaw playSdRaw4; //xy=510.33331298828125,337.33331298828125
AudioPlaySdRaw playSdRaw1; //xy=511.33331298828125,224.33334350585938
AudioPlaySdRaw playSdRaw3; //xy=511.33331298828125,299.33331298828125
AudioMixer4 mixer1; //xy=678.3333129882812,244.33334350585938
AudioMixer4 mixer2; //xy=678.3333129882812,318.33331298828125
AudioOutputI2S i2s1; //xy=816.3333129882812,279.33331298828125
AudioConnection patchCord1(playSdRaw2, 0, mixer1, 3);
AudioConnection patchCord2(playSdRaw4, 0, mixer2, 3);
AudioConnection patchCord3(playSdRaw1, 0, mixer1, 0);
AudioConnection patchCord4(playSdRaw3, 0, mixer2, 0);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
// GUItool: end automatically generated code
Anyhow, while I may be new to controllers I'm not new to electronics. For 35 years I've worked as a component level analog/digital electronics repair tech. Nine years of which was in the U.S. Air Force maintaining/repairing specialized equipment used to monitor nuclear weapons testing around the world. I've also got a background in programming. Was trained in COBOL (back in the 80's though), UNIX system admin (back when Solaris/Sparc 5's were around in the mid 90's), and my current job has me operating a Linux based test station.
Okay, enough of the unrelated chit chat. On to what brings me here and why I bought the Teensy 4.1. What I am trying to achieve is a control setup that will operate 4 independent stepper motors (little guys salvaged from CDROM drives that have the long drive screw for the read/write head) and each stepper motor will have a different sound file associated with it. While I think I understand what's needed for the stepper motor control (I'll have questions about that some other time) I'm currently trying to understand what my options are in regards to playing 4 RAW sound files at once. The sound files will be starting at different times so I can't merge them in to a single mp3 file. I watched the audio tutorial and saw how it showed 2 stereo mp3 files from an SD card being played simultaneously and 4 sample sounds being played at once. Using the Audio System Design Tool one option I'm looking at is something like the image below. It has 4 mono RAW sound files that are stored on the SD card. Two sound files need to be mixed together for the left speaker and the other 2 mixed together and routed to the right speaker. While this is more of a generic question and not about scripting (sketch) I've added the sketch text that the design tool provided at the end of my post just in case.
Since the overall output is still the standard stereo output of the audio card is this doable? If not would adding a W25Q128FV Serial Flash chip and storing the 4 sound RAW files on the flash memory by using playFlashRaw instead of playSDRaw? Here's what the design tool says about the playFlashRaw option.
Summary: Play a RAW data file, stored on a Serial Flash chip. These chips are far more efficient than SD cards, allowing many files to be played simultaneously by copies of this object.
I hope I've crossed all the i's and dotted all the required t's with my first post. I hope to learn more as this project progresses and I buy addition modules. Thanks in advance for any help that is provided towards completion of this project.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdRaw playSdRaw2; //xy=510.33331298828125,264.3333435058594
AudioPlaySdRaw playSdRaw4; //xy=510.33331298828125,337.33331298828125
AudioPlaySdRaw playSdRaw1; //xy=511.33331298828125,224.33334350585938
AudioPlaySdRaw playSdRaw3; //xy=511.33331298828125,299.33331298828125
AudioMixer4 mixer1; //xy=678.3333129882812,244.33334350585938
AudioMixer4 mixer2; //xy=678.3333129882812,318.33331298828125
AudioOutputI2S i2s1; //xy=816.3333129882812,279.33331298828125
AudioConnection patchCord1(playSdRaw2, 0, mixer1, 3);
AudioConnection patchCord2(playSdRaw4, 0, mixer2, 3);
AudioConnection patchCord3(playSdRaw1, 0, mixer1, 0);
AudioConnection patchCord4(playSdRaw3, 0, mixer2, 0);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
// GUItool: end automatically generated code