<commit_before>#include "synth.h"
#include "voice.h"
#include "frequencies.h"

AudioOutputI2S  audioOut;

Synth::Synth() {

  this->waveform1 = WAVEFORM_SINE;
  this->waveform2 = WAVEFORM_SINE;

  this->detune = 1;

  this->sustained = false;

  int patchCordIndex = 0;

  this->finalMixer = new AudioMixer4();
  this->filter = new AudioFilterStateVariable();

  this->patchCords[patchCordIndex++] = new AudioConnection(*this->finalMixer, 0, *this->filter, 0);

  this->lfo = new AudioSynthWaveform();
  this->lfo->begin(1, 1, WAVEFORM_SAMPLE_HOLD);
  
  this->filterSignalMixer = new AudioMixer4();
  this->filterSignalMixer->gain(0, 0.0);
  this->filterSignalMixer->gain(1, 0.7);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->lfo, 0, *this->filterSignalMixer, 0);
  
  this->filterSignalDc = new AudioSynthWaveformDc();
  this->filterSignalDc->amplitude(1);
  this->filterSignalEnvelope = new AudioEffectEnvelope();
  this->filterSignalEnvelope->attack(10.0);
  this->filterSignalEnvelope->decay(500.0);
  this->filterSignalEnvelope->sustain(0.0);
  this->filterSignalEnvelope->release(500.0);
  
  
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filterSignalDc, 0, *this->filterSignalEnvelope, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filterSignalEnvelope, 0, *this->filterSignalMixer, 1);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filterSignalMixer, 0, *this->filter, 1);
  

  this->amplitudeMixer = new AudioMixer4();
  this->amplitudeMixer->gain(0, 0.01);
  this->amplitudeMixer->gain(1, 0.99);
  this->amplitudeDc = new AudioSynthWaveformDc();
  this->amplitudeDc->amplitude(1);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->lfo, 0, *this->amplitudeMixer, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeDc, 0, *this->amplitudeMixer, 1);

  this->amplitudeModulation = new AudioEffectMultiply();
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filter, 0, *this->amplitudeModulation, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeMixer, 0, *this->amplitudeModulation, 1);

  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeModulation, 0, audioOut, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeModulation, 0, audioOut, 1);

  for (int i = 0; i < mergeMixerCount; i++) {
    this->mergeMixers[i] = new AudioMixer4();
    this->mergeMixers[i]->gain(0, 0.25);
    this->mergeMixers[i]->gain(1, 0.25);
    this->mergeMixers[i]->gain(2, 0.25);
    this->mergeMixers[i]->gain(3, 0.25);

    this->patchCords[patchCordIndex++] = new AudioConnection(*this->mergeMixers[i], 0, *this->finalMixer, i);
  }

  for (int i = 0; i < voiceCount; i++) {
    this->voices[i] = new Voice();
    this->notes[i] = 0;
    this->sustainedNotes[i] = 0;

    this->patchCords[patchCordIndex++] = new AudioConnection(*this->voices[i]->output, 0, *this->mergeMixers[i / channelsPerMixer], i % channelsPerMixer);
  }
}

Synth::~Synth() {

}

void Synth::setup() {

  // Audio setup.
  AudioMemory(50);

  this->codec.enable();

  this->setMasterVolume(0.5);

  this->setFilterLFOAmount(0);
  this->setAmplitudeModulationLFOAmount(0);

  this->codec.surroundSound(7, 1);
  this->codec.surroundSoundEnable();
}
<commit_msg>Initialize the sd card and the flash memory.<commit_after>#include "synth.h"
#include "voice.h"
#include "frequencies.h"

AudioOutputI2S  audioOut;

Synth::Synth() {

  this->waveform1 = WAVEFORM_SINE;
  this->waveform2 = WAVEFORM_SINE;

  this->detune = 1;

  this->sustained = false;

  int patchCordIndex = 0;

  this->finalMixer = new AudioMixer4();
  this->filter = new AudioFilterStateVariable();

  this->patchCords[patchCordIndex++] = new AudioConnection(*this->finalMixer, 0, *this->filter, 0);

  this->lfo = new AudioSynthWaveform();
  this->lfo->begin(1, 1, WAVEFORM_SAMPLE_HOLD);
  
  this->filterSignalMixer = new AudioMixer4();
  this->filterSignalMixer->gain(0, 0.0);
  this->filterSignalMixer->gain(1, 0.7);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->lfo, 0, *this->filterSignalMixer, 0);
  
  this->filterSignalDc = new AudioSynthWaveformDc();
  this->filterSignalDc->amplitude(1);
  this->filterSignalEnvelope = new AudioEffectEnvelope();
  this->filterSignalEnvelope->attack(10.0);
  this->filterSignalEnvelope->decay(500.0);
  this->filterSignalEnvelope->sustain(0.0);
  this->filterSignalEnvelope->release(500.0);
  
  
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filterSignalDc, 0, *this->filterSignalEnvelope, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filterSignalEnvelope, 0, *this->filterSignalMixer, 1);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filterSignalMixer, 0, *this->filter, 1);
  

  this->amplitudeMixer = new AudioMixer4();
  this->amplitudeMixer->gain(0, 0.01);
  this->amplitudeMixer->gain(1, 0.99);
  this->amplitudeDc = new AudioSynthWaveformDc();
  this->amplitudeDc->amplitude(1);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->lfo, 0, *this->amplitudeMixer, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeDc, 0, *this->amplitudeMixer, 1);

  this->amplitudeModulation = new AudioEffectMultiply();
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->filter, 0, *this->amplitudeModulation, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeMixer, 0, *this->amplitudeModulation, 1);

  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeModulation, 0, audioOut, 0);
  this->patchCords[patchCordIndex++] = new AudioConnection(*this->amplitudeModulation, 0, audioOut, 1);

  for (int i = 0; i < mergeMixerCount; i++) {
    this->mergeMixers[i] = new AudioMixer4();
    this->mergeMixers[i]->gain(0, 0.25);
    this->mergeMixers[i]->gain(1, 0.25);
    this->mergeMixers[i]->gain(2, 0.25);
    this->mergeMixers[i]->gain(3, 0.25);

    this->patchCords[patchCordIndex++] = new AudioConnection(*this->mergeMixers[i], 0, *this->finalMixer, i);
  }

  for (int i = 0; i < voiceCount; i++) {
    this->voices[i] = new Voice();
    this->notes[i] = 0;
    this->sustainedNotes[i] = 0;

    this->patchCords[patchCordIndex++] = new AudioConnection(*this->voices[i]->output, 0, *this->mergeMixers[i / channelsPerMixer], i % channelsPerMixer);
  }
}

Synth::~Synth() {

}

void Synth::setup() {

  // Audio setup.
  AudioMemory(50);

  this->codec.enable();

  this->setMasterVolume(0.5);

  this->setFilterLFOAmount(0);
  this->setAmplitudeModulationLFOAmount(0);

  this->codec.surroundSound(7, 1);
  this->codec.surroundSoundEnable();

  // Initialize the SD card
  SPI.setMOSI(7);
  SPI.setSCK(14);
  if (!(SD.begin(10))) {
    // stop here if no SD card, but print a message
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }

  // Initialize the serial flash chip.
  if (!SerialFlash.begin()) {
    Serial.println("Unable to access SPI Flash chip");
  }
}

{'fraction_non_alphanumeric': 0.17145270270270271, 'fraction_numerical': 0.027167792792792793, 'mean_word_length': 5.067463706233988, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1162896', 'n_tokens_mistral': 2716, 'n_tokens_neox': 2510, 'n_words': 425}