snapshot
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const unsigned char g8_saw_raw[] = {
|
||||
0x00, 0x00, 0xb5, 0x0b, 0x69, 0x17, 0x22, 0x23, 0xd3, 0x2e, 0x8b, 0x3a,
|
||||
0x3e, 0x46, 0xf2, 0x51, 0x79, 0xaa, 0x29, 0xb6, 0xe3, 0xc1, 0x93, 0xcd,
|
||||
0x4a, 0xd9, 0x02, 0xe5, 0xb3, 0xf0, 0x6b, 0xfc, 0x1f, 0x08, 0xd3, 0x13,
|
||||
0x8c, 0x1f, 0x3b, 0x2b, 0xf8, 0x36, 0xa5, 0x42, 0x61, 0x4e, 0xdd, 0xa6,
|
||||
0x98, 0xb2, 0x48, 0xbe, 0x00, 0xca, 0xb5, 0xd5, 0x69, 0xe1, 0x1e, 0xed,
|
||||
0xd8, 0xf8, 0x84, 0x04, 0x42, 0x10, 0xf1, 0x1b, 0xa8, 0x27, 0x62, 0x33,
|
||||
0x0e, 0x3f, 0xcd, 0x4a, 0x78, 0x56, 0x03, 0xaf, 0xb1, 0xba, 0x6c, 0xc6,
|
||||
0x1e, 0xd2, 0xd3, 0xdd, 0x89, 0xe9, 0x3e, 0xf5, 0xf4, 0x00, 0xa6, 0x0c,
|
||||
0x61, 0x18, 0x0e, 0x24, 0xcd, 0x2f, 0x78, 0x3b, 0x37, 0x47, 0xe2, 0x52,
|
||||
0x6e, 0xab, 0x1a, 0xb7, 0xd6, 0xc2, 0x89, 0xce, 0x3c, 0xda, 0xf4, 0xe5,
|
||||
0xa7, 0xf1, 0x5d, 0xfd
|
||||
};
|
||||
unsigned int g8_saw_raw_len = 124;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
const unsigned char g8_sine_raw[] = {
|
||||
0x00, 0x00, 0xc1, 0x23, 0x93, 0x41, 0x7e, 0x54, 0x5e, 0x59, 0x6a, 0x4f,
|
||||
0x3b, 0x38, 0xc0, 0x17, 0x46, 0xf3, 0xf6, 0xd0, 0x69, 0xb6, 0x26, 0xa8,
|
||||
0x6d, 0xa8, 0x4b, 0xb7, 0x3a, 0xd2, 0xc2, 0xf4, 0x2c, 0x19, 0x67, 0x39,
|
||||
0x14, 0x50, 0x7a, 0x59, 0xf9, 0x53, 0x8e, 0x40, 0x5f, 0x22, 0x86, 0xfe,
|
||||
0xde, 0xda, 0x6f, 0xbd, 0x03, 0xab, 0xc1, 0xa6, 0x4b, 0xb1, 0xed, 0xc8,
|
||||
0xb6, 0xe9, 0x2e, 0x0e, 0x53, 0x30, 0x69, 0x4a, 0x26, 0x58, 0x3d, 0x57,
|
||||
0xd3, 0x47, 0x7e, 0x2c, 0xc1, 0x09, 0x66, 0xe5, 0x79, 0xc5, 0x3f, 0xaf,
|
||||
0x7a, 0xa6, 0x89, 0xac, 0x83, 0xc0, 0xfc, 0xde
|
||||
};
|
||||
unsigned int g8_sine_raw_len = 92;
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "g8-sine.h"
|
||||
#include "g8-sine-long.h"
|
||||
#include "g8-saw.h"
|
||||
|
||||
// sawtooth note g8 recorded at 96000
|
||||
MemoryStream toneG8(g8_sine_raw, g8_sine_raw_len);
|
||||
// playback at 24000 (4 times slower)
|
||||
const AudioInfo info(24000,1,16);
|
||||
AudioBoardStream i2s(AudioKitEs8388V1);
|
||||
CsvOutput<int16_t> csv(Serial, 1);
|
||||
//FilteredStream<int16_t, int16_t> filter(i2s, 1);
|
||||
ResampleStream resample(csv); // replace with i2s
|
||||
StreamCopy copier(resample, toneG8, 2048); // copies sound to out
|
||||
int idx_max = 100;
|
||||
int idx = idx_max;
|
||||
MusicalNotes notes;
|
||||
uint32_t timeout = 0;
|
||||
|
||||
void changeNote() {
|
||||
const float from_tone = N_G8;
|
||||
// e.g. 6271.93f / 16.35f * 4.0 = 0.01042741229
|
||||
float step_size = notes.frequency(idx) / from_tone * 4.0f;
|
||||
Serial.print("playing note: ");
|
||||
Serial.print(notes.noteAt(idx));
|
||||
Serial.print(" / step: ");
|
||||
Serial.println(step_size);
|
||||
|
||||
resample.setStepSize(step_size);
|
||||
idx--;
|
||||
if (idx < 0) {
|
||||
idx = idx_max;
|
||||
Serial.println("-----------------------");
|
||||
}
|
||||
timeout = millis() + 1000;
|
||||
}
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
// Open Serial
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// filter.setFilter(0, new MedianFilter<int16_t>(7));
|
||||
// filter.begin(info);
|
||||
|
||||
// open input
|
||||
toneG8.begin();
|
||||
toneG8.setLoop(true);
|
||||
|
||||
// open resample
|
||||
auto rcfg = resample.defaultConfig();
|
||||
rcfg.copyFrom(info);
|
||||
resample.begin(rcfg);
|
||||
//resample.setBuffered(false);
|
||||
|
||||
// open i2s output
|
||||
auto cfg = i2s.defaultConfig();
|
||||
cfg.copyFrom(info);
|
||||
i2s.begin(cfg);
|
||||
i2s.setVolume(0.3);
|
||||
}
|
||||
|
||||
// Arduino loop - copy sound to out
|
||||
void loop() {
|
||||
if (millis() > timeout) {
|
||||
changeNote();
|
||||
}
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user