|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
-
-
-
-
-
-
-
-
-
-
-
-
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SerialFlash.h>
-
-
- AudioSynthWaveformSine sine1;
- AudioOutputI2S i2s1;
- AudioConnection patchCord1(sine1, 0, i2s1, 0);
- AudioConnection patchCord2(sine1, 0, i2s1, 1);
- AudioControlSGTL5000 sgtl5000_1;
-
-
-
- elapsedMillis msec;
- float vol;
- float inc;
- int rampType;
- const char *rampName[] = {
- "No Ramp (instant)",
- "Normal Ramp",
- "Linear Ramp"
- };
-
- void setup(void) {
- Serial.begin(9600);
-
- AudioMemory(4);
- vol = 0.0;
- inc = 0.2;
-
- rampType = 0;
-
- sine1.amplitude(1.0);
- sine1.frequency(440);
-
- sgtl5000_1.enable();
- sgtl5000_1.volume(0.5);
- sgtl5000_1.dacVolume(0);
- sgtl5000_1.dacVolumeRampDisable();
-
- Serial.println("setup done");
- }
-
- void loop(void) {
- if (msec > 1000) {
-
-
- vol += inc;
- if (vol >= 1.0) {
- vol = 1.0;
- inc = -inc;
- }
- if (vol < 0.01) {
- vol = 0.0;
- inc = -inc;
- }
- Serial.print("Volume: ");
- Serial.print(vol);
- Serial.print(" ");
- Serial.println(rampName[rampType]);
-
-
- if (rampType == 0) {
- sgtl5000_1.dacVolumeRampDisable();
- } else if (rampType == 1) {
- sgtl5000_1.dacVolumeRamp();
- } else {
- sgtl5000_1.dacVolumeRampLinear();
- }
-
-
-
-
- sgtl5000_1.dacVolume(vol);
-
-
- if (vol < 0.01) {
- rampType = rampType + 1;
- if (rampType > 2) rampType = 0;
- }
- msec = 0;
- }
- }
-
-
-
|