-
-
Notifications
You must be signed in to change notification settings - Fork 353
Expand file tree
/
Copy pathwav_encode.ino
More file actions
42 lines (38 loc) · 927 Bytes
/
wav_encode.ino
File metadata and controls
42 lines (38 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file aac_encode.ino
* @author Phil Schatzmann
* @brief Encode pwm data to AAC Stream (SD file)
* @version 0.1
* @date 2021-01-24
*
* @copyright Copyright (c) 2021
*
*/
#include <SPI.h>
#include <SD.h>
#include "WAVEncoder.h"
#include "StarWars30.h"
#include "AudioTools.h"
File dataFile = SD.open("example.wav", FILE_WRITE);
WAVEncoder encoder(dataFile);
MemoryStream music(StarWars30_raw, StarWars30_raw_len);
void setup(){
Serial.begin(115200);
SD.begin();
// setup encoder
encoder.begin();
Serial.println("Creating WAV file...");
}
void loop(){
static uint8_t buffer[512];
if (dataFile){
if (music.available()>0){
int len = music.readBytes(buffer, 512);
encoder.write(buffer, len);
} else {
// no more data -> close file
dataFile.close();
Serial.println("File has been closed");
}
}
}