forked from derkling/rtos2013
-
Notifications
You must be signed in to change notification settings - Fork 1
/
visualize.cpp
50 lines (41 loc) · 1.12 KB
/
visualize.cpp
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
43
44
45
46
47
48
49
50
#include <cstdio>
#include "miosix.h"
#include "Microphone.h"
#include "player.h"
#include <math.h>
#include <tr1/functional>
using namespace std;
using namespace std::tr1;
using namespace miosix;
/*
* This example program streams on the serial every 15ms of audio as couples time:val
* each representing 1 PCM sample. Every 15 second the word "new" is sent.
* With this you can use the plot.py program to see the waveform.
*/
void visualize(unsigned short* PCM, unsigned short size){
iprintf("new\n");
for(int i = 0; i < size; i++){
iprintf("%d:%d\n", i, (short) PCM[i] ); // prints key:val
}
}
int main()
{
bool lit = false;
Microphone& mic = Microphone::instance();
static const unsigned short size = 661; // sets 15ms (almost)
// init the Microphone driver
mic.init(&visualize,size);
// recording.
mic.start();
while (1){
// shows that you can do something else in the meanwhile
if(lit){
lit=false;
ledOff();
} else {
lit = true;
ledOn();
}
delayMs(500);
};
}