File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
examples/examples-stream/streams-i2s-i2s Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* *
2
+ * @file streams-i2s-i2s.ino
3
+ * @brief Copy audio from I2S to I2S
4
+ * @author Phil Schatzmann
5
+ * @copyright GPLv3
6
+ */
7
+
8
+ #include " AudioTools.h"
9
+
10
+ uint16_t sample_rate=44100 ;
11
+ uint16_t channels = 2 ;
12
+ I2SStream in;
13
+ I2SStream out;
14
+ StreamCopy copier (out, in); // copies sound into i2s
15
+ ConverterScaler<int16_t > scaler (0.8 , 0 , 32767 ); // change the signal
16
+
17
+ // Arduino Setup
18
+ void setup (void ) {
19
+ // Open Serial
20
+ Serial.begin (115200 );
21
+ AudioLogger::instance ().begin (Serial, AudioLogger::Info);
22
+
23
+ // start I2S in
24
+ Serial.println (" starting I2S..." );
25
+ auto config = in.defaultConfig (RX_MODE);
26
+ config.sample_rate = sample_rate;
27
+ config.bits_per_sample = 16 ;
28
+ config.i2s_format = I2S_STD_FORMAT;
29
+ config.is_master = true ;
30
+ config.port_no = 0 ;
31
+ in.begin (config);
32
+
33
+ // start I2S out
34
+ auto config_out = out.defaultConfig (TX_MODE);
35
+ config.sample_rate = sample_rate;
36
+ config.bits_per_sample = 16 ;
37
+ config.i2s_format = I2S_STD_FORMAT;
38
+ config.is_master = true ;
39
+ config.port_no = 1 ;
40
+ out.begin (config_out);
41
+
42
+ Serial.println (" I2S started..." );
43
+ }
44
+
45
+ // Arduino loop - copy audio to out
46
+ void loop () {
47
+ copier.copy (scaler);
48
+ }
You can’t perform that action at this time.
0 commit comments