void Adafruit_DRV2605::playLibraryEffects(std::vector<int> & effects) { for (unsigned int i = 0; i < effects.size(); i++) { setWaveform(i, effects[i]); if (i >= 7) break; } setWaveform(effects.size(), 0); go(); }
Lfo::Lfo(float samplerate) : samplerate(samplerate), phase(0), inc(0) { setWaveform(0); setWaveform(1); setWaveform(2); setWaveform(3); setWaveform(4); setRate(1.0f); //1Hz noiseOsc= new OscNoise(samplerate); randomValue= 0.0f; randomValueOld= 0.0f; resultSmooth= 0.0f; }
OscillatorNode::OscillatorNode(AudioContext* audioContext, WaveformType wavetype) : AudioNode(audioContext), AudioSourceNode() { _period = 0; _phase = 0; _osc = 0; _sample = 0; _accumulator = 0; _index = 0; setWaveform(wavetype); _freq = 150; frequency.value = _freq; frequency.value.reset(); setFrequency(_freq); _detune = 0; detune.value = _detune; detune.value.reset(); _portamento = 1; portamento.value = _portamento; portamento.value.reset(); _gain = 65535; gain.value = 1.0f; gain.value.reset(); }
LFO::LFO(float samplerate) : samplerate(samplerate), phase(0), inc(0) { setWaveform(LFO::sinus); setRate(1.0f); //1Hz }
LFO::LFO(float samplerate, const float rate, waveform_t waveform) : samplerate(samplerate), phase(0), inc(0) { setWaveform(waveform); // default triangle setRate(rate); // default 1 Hz }
int changeFrequency(int freq, int mode, int waveDacId) { int fnGenerator, numSamples; uint8 *currentWaveform; if (freq < FREQ_LOWER_LIMIT) { freq = FREQ_LOWER_LIMIT; } else if (freq > FREQ_UPPER_LIMIT) { freq = FREQ_UPPER_LIMIT; } if (freq < 2000) { if (waveDacId == 0) { fnGenerator = WAVEDAC_LOW_0; } else if (waveDacId == 1) { fnGenerator = WAVEDAC_LOW_1; } numSamples = WAVEDAC_CLOCK_LOW_FREQ / freq; } else { if (waveDacId == 0) { fnGenerator = WAVEDAC_HIGH_0; } else if (waveDacId == 1) { fnGenerator = WAVEDAC_HIGH_1; } numSamples = WAVEDAC_CLOCK_HIGH_FREQ / freq; } currentWaveform = getCurrentWaveform(fnGenerator); if (currentWaveform != NULL) { stopWaveDac(fnGenerator); setWaveform(numSamples, mode, currentWaveform); startWaveDac(numSamples, fnGenerator, currentWaveform); return freq; } return -1; }