|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SerialFlash.h>
-
-
- AudioSynthWaveformSine sine1;
- AudioSynthNoisePink pink1;
- AudioEffectEnvelope envelope1;
- AudioEffectEnvelope envelope2;
- AudioAnalyzeFFT256 fft256_1;
- AudioMixer4 mixer1;
- AudioOutputI2S i2s1;
- AudioConnection patchCord1(sine1, envelope2);
- AudioConnection patchCord2(sine1, fft256_1);
- AudioConnection patchCord3(pink1, envelope1);
- AudioConnection patchCord4(envelope1, 0, mixer1, 0);
- AudioConnection patchCord5(envelope2, 0, mixer1, 1);
- AudioConnection patchCord6(mixer1, 0, i2s1, 0);
- AudioConnection patchCord7(mixer1, 0, i2s1, 1);
- AudioControlSGTL5000 sgtl5000_1;
-
-
-
- void setup() {
-
-
-
- AudioMemory(20);
-
-
- sgtl5000_1.enable();
- sgtl5000_1.volume(0.6);
-
-
-
- pink1.amplitude(0.5);
- envelope1.attack(1.5);
- envelope1.hold(5);
- envelope1.decay(20);
- envelope1.sustain(0);
-
-
- sine1.frequency(120);
- sine1.amplitude(0.6);
- envelope2.attack(6.5);
- envelope2.hold(25);
- envelope2.decay(70);
- envelope2.sustain(0);
-
-
- mixer1.gain(0, 0.5);
- mixer1.gain(1, 0.5);
- }
-
-
- int count = 0;
- int speed = 60;
-
-
- void loop() {
-
- count = count + 1;
- if (count >= 16) count = 0;
-
-
- if (count == 0) envelope1.noteOn();
- if (count == 4) envelope1.noteOn();
- if (count == 8) envelope1.noteOn();
- if (count == 12) envelope1.noteOn();
-
-
- if (count == 4) {
- sine1.amplitude(0.6);
- sine1.frequency(100);
- envelope2.noteOn();
- }
- if (count == 12) {
- sine1.amplitude(0.3);
- sine1.frequency(120);
- envelope2.noteOn();
- }
-
-
-
-
- if (count == 6) {
- sine1.amplitude(0);
- }
-
-
- if (Serial.available()) {
- char c = Serial.read();
- if ((c == 'r' || c == 'R')) {
- pink1.processorUsageMaxReset();
- fft256_1.processorUsageMaxReset();
- AudioProcessorUsageMaxReset();
- AudioMemoryUsageMaxReset();
- Serial.println("Reset all max numbers");
- }
- if ((c == 'f' || c == 'F') && speed > 16) {
- speed = speed - 2;
- }
- if ((c == 's' || c == 'S') && speed < 250) {
- speed = speed + 2;
- }
- }
-
-
- Serial.print("CPU: ");
- Serial.print("pink=");
- Serial.print(pink1.processorUsage());
- Serial.print(",");
- Serial.print(pink1.processorUsageMax());
- Serial.print(" ");
- Serial.print("fft=");
- Serial.print(fft256_1.processorUsage());
- Serial.print(",");
- Serial.print(fft256_1.processorUsageMax());
- Serial.print(" ");
- Serial.print("all=");
- Serial.print(AudioProcessorUsage());
- Serial.print(",");
- Serial.print(AudioProcessorUsageMax());
- Serial.print(" ");
- Serial.print("Memory: ");
- Serial.print(AudioMemoryUsage());
- Serial.print(",");
- Serial.print(AudioMemoryUsageMax());
- Serial.print(" ");
- Serial.print("Send: (R)eset, (S)lower, (F)aster");
- Serial.println();
-
-
- delay(speed);
-
- }
-
|