-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #21: apply map function before hysteresis
- Loading branch information
Showing
9 changed files
with
154 additions
and
31 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
examples/Boards/Teensy/Audio/1.Volume-Controlled-USB-DAC/1.Volume-Controlled-USB-DAC.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* This is an example of the VolumeControl class of the Control Surface library. | ||
* | ||
* @boards Teensy 3.x | ||
* | ||
* Connections | ||
* ----------- | ||
* | ||
* - A0: wiper of a potentiometer to change the output volume | ||
* - 9: BCK (I²S) | ||
* - 11: SCK (I²S) | ||
* - 22: DIN (I²S) | ||
* - 23: LRCK (I²S) | ||
* | ||
* Select a USB audio option from the Tools menu in the IDE. | ||
* | ||
* Behavior | ||
* -------- | ||
* | ||
* Upload the sketch, and select the Control Surface as the audio output of your | ||
* computer. Connect the output of the DAC to a pair of headphones or powered | ||
* speakers, and play some music. | ||
* You can now adjust the volume using the potentiometer. | ||
* | ||
* Mapping | ||
* ------- | ||
* | ||
* None. | ||
* | ||
* Written by | ||
* | ||
*/ | ||
|
||
#include <Control_Surface.h> // Include the Control Surface library | ||
|
||
AudioInputUSB audioInputUSB; // The audio input from the USB connection | ||
AudioMixer4 mixer_L; // Two mixers for volume control | ||
AudioMixer4 mixer_R; | ||
AudioOutputI2S audioOutputI2S; // The output to the I²S DAC | ||
|
||
AudioConnection patchCord1(audioInputUSB, 0, mixer_L, 0); // Connect the input | ||
AudioConnection patchCord3(audioInputUSB, 1, mixer_R, 0); // to the mixer | ||
AudioConnection patchCord5(mixer_L, 0, audioOutputI2S, 1); // Connect the mixer | ||
AudioConnection patchCord6(mixer_R, 0, audioOutputI2S, 0); // to the output | ||
|
||
// Instantiate a VolumeControl object with a potentiometer on pin A0 and a | ||
// maximum gain of 1.0 | ||
VolumeControl<2> volume = {{&mixer_L, &mixer_R}, A0, 1.0}; | ||
|
||
void setup() { | ||
volume.begin(); | ||
// Add a dead zone if you can't get the volume all the way to zero | ||
// volume.map([](analog_t i) -> analog_t { | ||
// return map(constrain(i, 10, 1013), 10, 1013, 0, 1023); | ||
// }); | ||
AudioMemory(6); | ||
} | ||
|
||
void loop() { | ||
volume.update(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters