|
| 1 | +# ML_SynthTools Library with Teensy |
| 2 | + |
| 3 | +This guide explains how to use the `ML_SynthTools` library with the Teensy board, including necessary modifications to ensure proper functionality. Follow the steps below to integrate and configure everything correctly. |
| 4 | + |
| 5 | +## Required Changes to Teensy Setup |
| 6 | + |
| 7 | +To use `ML_SynthTools` with the Teensy, there are a few modifications that need to be made to the Teensy core files. These changes adjust linker flags and audio settings for compatibility with your library. |
| 8 | + |
| 9 | +### 1. Add Linker Flags to `platform.txt` |
| 10 | + |
| 11 | +To configure the correct linker flags, you need to modify the `platform.txt` file for Teensy. This ensures that the necessary libraries are linked correctly. |
| 12 | + |
| 13 | +- Locate the `platform.txt` file in the following directory: |
| 14 | + ``` |
| 15 | + %appdata%\..\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\platform.txt |
| 16 | + ``` |
| 17 | + |
| 18 | +- Open the file in a text editor, and add the following line under the section for `compiler.libraries.ldflags`: |
| 19 | + ``` |
| 20 | + compiler.libraries.ldflags= |
| 21 | + ``` |
| 22 | + |
| 23 | +This will enable the necessary linker flags required by `ML_SynthTools`. |
| 24 | + |
| 25 | +### 2. Modify Audio Stream Header for Block Size and Sample Rate |
| 26 | + |
| 27 | +Next, you need to update some audio settings in the Teensy core to ensure compatibility with the `ML_SynthTools` library. |
| 28 | + |
| 29 | +- Navigate to the following Teensy file: |
| 30 | + ``` |
| 31 | + %appdata%\..\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4\AudioStream.h |
| 32 | + ``` |
| 33 | + |
| 34 | +- Open the file and locate the line: |
| 35 | + ``` c |
| 36 | + #define AUDIO_BLOCK_SAMPLES 128 |
| 37 | + ``` |
| 38 | +
|
| 39 | +- Change it to: |
| 40 | + ``` c |
| 41 | + #define AUDIO_BLOCK_SAMPLES 48 |
| 42 | + ``` |
| 43 | + |
| 44 | + This modification adjusts the number of audio samples in each audio block for better performance with the `ML_SynthTools` library. |
| 45 | + |
| 46 | +- Next, find the line: |
| 47 | + ``` c |
| 48 | + #define AUDIO_SAMPLE_RATE_EXACT 44100.0f |
| 49 | + ``` |
| 50 | +
|
| 51 | +- Change it to: |
| 52 | + ``` c |
| 53 | + #define AUDIO_SAMPLE_RATE_EXACT 48000.0f |
| 54 | + ``` |
| 55 | + |
| 56 | + This sets the audio sample rate to 48 kHz, which is required for the correct operation of `ML_SynthTools`. |
| 57 | + |
| 58 | +## Installation Steps |
| 59 | + |
| 60 | +1. **Install Teensyduino:** If you haven't already, make sure to install [Teensyduino](https://www.pjrc.com/teensy/teensyduino.html), which provides the necessary libraries and tools for programming the Teensy board. |
| 61 | +
|
| 62 | +2. **Install `ML_SynthTools` Library:** |
| 63 | + - Download or clone the `ML_SynthTools` library to your Arduino libraries folder. |
| 64 | + - You can also install it via the Arduino Library Manager (if available). |
| 65 | +
|
| 66 | +3. **Configure the Teensy Board:** |
| 67 | + - In the Arduino IDE, go to **Tools** > **Board** and select your Teensy model. |
| 68 | + - Set the correct COM port for the Teensy. |
| 69 | +
|
| 70 | +4. **Upload Your Code:** |
| 71 | + - Once the above steps are completed, upload your code that uses the `ML_SynthTools` library to your Teensy board. |
| 72 | +
|
| 73 | +## Conclusion |
| 74 | +
|
| 75 | +After making these changes, you should be able to use the `ML_SynthTools` library with your Teensy board. If you encounter any issues, make sure all modifications are correctly applied and that the Teensy board is properly selected in the Arduino IDE. |
0 commit comments