Browse Source

Impove SimpleWavetable example

dds
PaulStoffregen 6 years ago
parent
commit
8557edb234
5 changed files with 3251 additions and 3610 deletions
  1. +0
    -3590
      examples/Synthesis/Wavetable/SimpleWavetable/BasicFlute1_samples.cpp
  2. +0
    -10
      examples/Synthesis/Wavetable/SimpleWavetable/BasicFlute1_samples.h
  3. +3244
    -0
      examples/Synthesis/Wavetable/SimpleWavetable/Flute_100kbyte_samples.cpp
  4. +3
    -0
      examples/Synthesis/Wavetable/SimpleWavetable/Flute_100kbyte_samples.h
  5. +4
    -10
      examples/Synthesis/Wavetable/SimpleWavetable/SimpleWavetable.ino

+ 0
- 3590
examples/Synthesis/Wavetable/SimpleWavetable/BasicFlute1_samples.cpp
File diff suppressed because it is too large
View File


+ 0
- 10
examples/Synthesis/Wavetable/SimpleWavetable/BasicFlute1_samples.h View File

#pragma once
#include <Audio.h>

extern const AudioSynthWavetable::sample_data BasicFlute1_samples[1];
const uint8_t BasicFlute1_ranges[] = {127,};

const AudioSynthWavetable::instrument_data BasicFlute1 = {1, BasicFlute1_ranges, BasicFlute1_samples };


extern const uint32_t sample_0_BasicFlute1_BreathyFluteC2[28544];

+ 3244
- 0
examples/Synthesis/Wavetable/SimpleWavetable/Flute_100kbyte_samples.cpp
File diff suppressed because it is too large
View File


+ 3
- 0
examples/Synthesis/Wavetable/SimpleWavetable/Flute_100kbyte_samples.h View File

#pragma once
#include <Audio.h>
extern const AudioSynthWavetable::instrument_data Flute_100kbyte;

+ 4
- 10
examples/Synthesis/Wavetable/SimpleWavetable/SimpleWavetable.ino View File

#include <SD.h> #include <SD.h>
#include <SerialFlash.h> #include <SerialFlash.h>


#include "BasicFlute1_samples.h"
#include "Flute_100kbyte_samples.h"


AudioSynthWavetable wavetable; AudioSynthWavetable wavetable;
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioControlSGTL5000 sgtl5000_1; AudioControlSGTL5000 sgtl5000_1;


// Bounce objects to read pushbuttons // Bounce objects to read pushbuttons
Bounce button0 = Bounce(0, 15);
Bounce button1 = Bounce(1, 15); // 15 ms debounce time Bounce button1 = Bounce(1, 15); // 15 ms debounce time
Bounce button2 = Bounce(2, 15);


void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP); pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
AudioMemory(20); AudioMemory(20);
sgtl5000_1.enable(); sgtl5000_1.enable();
sgtl5000_1.volume(0.8); sgtl5000_1.volume(0.8);
mixer.gain(0, 0.7); mixer.gain(0, 0.7);
wavetable.setInstrument(BasicFlute1);
wavetable.setInstrument(Flute_100kbyte);
wavetable.amplitude(1); wavetable.amplitude(1);
} }




void loop() { void loop() {
// Update all the button objects // Update all the button objects
button0.update();
button1.update(); button1.update();
button2.update();
//Read knob values //Read knob values
int knob1 = analogRead(A3); int knob1 = analogRead(A3);
int knob2 = analogRead(A2); int knob2 = analogRead(A2);
//Get frequency and gain from knobs
float freq = (float)knob1/5.0;
//Get frequency and gain from knobs (Flute range is 261 to 2100 Hz)
float freq = 261.0 + (float)knob1/1023.0 * (2100.0 - 261.0);
float gain = (float)knob2/1023.0; float gain = (float)knob2/1023.0;
//Set a low-limit to the gain //Set a low-limit to the gain
if (gain < .05) gain = .05; if (gain < .05) gain = .05;

Loading…
Cancel
Save