File tree Expand file tree Collapse file tree 3 files changed +13
-17
lines changed Expand file tree Collapse file tree 3 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ RECURSIVE_FIND_FILE(LIB_ARCHIVE_FILES "${CMAKE_CURRENT_LIST_DIR}/lib" "*.a")
50
50
51
51
set (CMAKE_SYSTEM_PROCESSOR "armv7-m" PARENT_SCOPE)
52
52
53
- set (ROOT "${CMAKE_CURRENT_LIST_DIR} /CMSIS_5/ " )
53
+ set (ROOT "${CMAKE_CURRENT_LIST_DIR} /CMSIS_5" )
54
54
list (APPEND INCLUDE_DIRS "${ROOT} /CMSIS/Core/Include/" )
55
55
56
56
Original file line number Diff line number Diff line change 2
2
#include " CodalDmesg.h"
3
3
#include " MicroBitAudioProcessor.h"
4
4
#include " StreamNormalizer.h"
5
- #include " Tests.h"
6
5
7
6
static NRF52ADCChannel *mic = NULL ;
8
7
static StreamNormalizer *processor = NULL ;
@@ -14,8 +13,9 @@ MicroBit uBit;
14
13
* fft_test function - creates an example MicroBitAudioProcessor and then queries it for results.
15
14
* Currently configured to use 1024 samples with 8bit signed data.
16
15
*/
17
- void fft_test (){
16
+ void fft_test () {
18
17
uBit.display .print (" L" );
18
+ /*
19
19
if (mic == NULL){
20
20
mic = uBit.adc.getChannel(uBit.io.microphone);
21
21
mic->setGain(7,0);
@@ -29,13 +29,17 @@ void fft_test(){
29
29
30
30
uBit.io.runmic.setDigitalValue(1);
31
31
uBit.io.runmic.setHighDrive(true);
32
+ */
32
33
34
+ // Code above commented out was from the original example, which can
35
+ // probably be replaced with this single line, but we need to double check
36
+ // the configuration because the fft calculation results are twice the frequency
37
+ fft = new MicroBitAudioProcessor (*uBit.audio .splitter ->createChannel ());
33
38
34
39
// Start fft running
35
40
fft->startRecording ();
36
41
37
-
38
- while (1 ){
42
+ while (1 ){
39
43
// TODO - de-noise : if last X samples are same - display ect.
40
44
// The output values depend on the input type (DATASTREAM_FORMAT_8BIT_SIGNED) and the size
41
45
// of the FFT - which is changed using the 'AUDIO_SAMPLES_NUMBER' in MicroBitAudioProcessor.h
@@ -64,13 +68,7 @@ void fft_test(){
64
68
}
65
69
}
66
70
67
-
68
-
69
- int
70
- main ()
71
- {
72
-
71
+ int main () {
73
72
uBit.init ();
74
73
fft_test ();
75
-
76
- }
74
+ }
Original file line number Diff line number Diff line change @@ -55,8 +55,6 @@ MicroBitAudioProcessor::~MicroBitAudioProcessor()
55
55
56
56
int MicroBitAudioProcessor::pullRequest ()
57
57
{
58
-
59
- int s;
60
58
int result;
61
59
62
60
auto mic_samples = audiostream.pull ();
@@ -99,9 +97,9 @@ int MicroBitAudioProcessor::pullRequest()
99
97
// DMESG("Before FFT: %d", (int)a);
100
98
// DMESG("After FFT: %d (%d)", (int)b, (int)(b - a));
101
99
102
- uint32_t freq = ((uint32_t )MIC_SAMPLE_RATE / AUDIO_SAMPLES_NUMBER) * (index + 1 );
100
+ lastFreq = ((uint32_t )MIC_SAMPLE_RATE / AUDIO_SAMPLES_NUMBER) * (index + 1 );
103
101
DMESG (" Freq: %d (max: %d.%d, Index: %d)" ,
104
- freq ,
102
+ lastFreq ,
105
103
(int )maxValue,
106
104
((int )(maxValue * 100 ) % 100 ),
107
105
index);
You can’t perform that action at this time.
0 commit comments