@@ -58,18 +58,18 @@ void stream_test_record() {
5858 static StreamRecording * recording = new StreamRecording ( *input );
5959 static MixerChannel * output = uBit.audio .mixer .addChannel ( *recording );
6060
61- // FIXME: Update this to use the new requestSampleRate
62- // input->requestSampleRate( 11000 );
61+ uBit.audio .mic ->setSampleRate ( 11000 );
6362 output->setSampleRate ( 11000 );
64- output->setVolume ( CONFIG_MIXER_INTERNAL_RANGE * 0.8 ); // 80% volume
63+
64+ output->setVolume ( CONFIG_MIXER_INTERNAL_RANGE * 0.2 ); // 20% volume
6565
6666 uBit.display .printChar ( ' 3' , 1000 );
6767 uBit.display .printChar ( ' 2' , 1000 );
6868 uBit.display .printChar ( ' 1' , 1000 );
6969
7070 uBit.display .printChar ( ' R' );
71- // FIXME: Update this to use the new requestSampleRate
72- // input->requestSampleRate( 11000 );
71+ uBit. audio . mic -> setSampleRate ( 11000 );
72+
7373 recording->recordAsync ();
7474 while ( recording->isRecording () ) {
7575 uBit.display .printChar ( ' ~' );
@@ -101,14 +101,13 @@ static const int STRSR_SAMPLE_RATE = 11000;
101101
102102static void strsr_handle_buttonA (MicroBitEvent) {
103103 static SplitterChannel *splitterChannel = uBit.audio .splitter ->createChannel ();
104- // FIXME: Update this to use the new requestSampleRate
105- // splitterChannel->requestSampleRate(STRSR_SAMPLE_RATE);
104+ uBit.audio .mic ->setSampleRate ( STRSR_SAMPLE_RATE );
106105 static StreamRecording *recording = new StreamRecording (*splitterChannel);
107106 static MixerChannel *channel = uBit.audio .mixer .addChannel (*recording, STRSR_SAMPLE_RATE);
108107
109108 DMESG ( " Actual sample rate: %d (requested %d)" , (int )splitterChannel->getSampleRate (), STRSR_SAMPLE_RATE );
110109
111- MicroBitAudio:: requestActivation ();
110+ uBit. audio . requestActivation ();
112111 channel->setVolume (75.0 );
113112 uBit.audio .mixer .setVolume (512 );
114113 uBit.audio .mixer .setSilenceLevel ( 0 );
@@ -117,24 +116,20 @@ static void strsr_handle_buttonA(MicroBitEvent) {
117116 uBit.display .clear ();
118117 uBit.audio .levelSPL ->setUnit (LEVEL_DETECTOR_SPL_8BIT);
119118
120- // FIXME: Update this to use the new requestSampleRate
121- // splitterChannel->requestSampleRate( STRSR_SAMPLE_RATE );
119+ uBit.audio .mic ->setSampleRate ( STRSR_SAMPLE_RATE );
122120
123121 DMESG ( " RECORDING" );
124122 recording->recordAsync ();
125123 bool showR = true ;
126124 while (uBit.buttonA .isPressed ()) {
127125 if ( uBit.logo .isPressed () ) {
128- // FIXME: Update this to use the new requestSampleRate
129- // splitterChannel->requestSampleRate( abs((uBit.accelerometer.getRoll()-90) * 100) );
126+ uBit.audio .mic ->setSampleRate ( abs ((uBit.accelerometer .getRoll ()-90 ) * 100 ) );
130127 DMESG ( " Sample Rate: %d (mic = %d)" , (int )splitterChannel->getSampleRate (), (int )uBit.audio .mic ->getSampleRate () );
131128 } else {
132- if ( uBit.buttonB .isPressed () ) {}
133- // FIXME: Update this to use the new requestSampleRate
134- // splitterChannel->requestSampleRate( 5000 );
135- else {}
136- // FIXME: Update this to use the new requestSampleRate
137- // splitterChannel->requestSampleRate( STRSR_SAMPLE_RATE );
129+ if ( uBit.buttonB .isPressed () )
130+ uBit.audio .mic ->setSampleRate (5000 );
131+ else
132+ uBit.audio .mic ->setSampleRate (STRSR_SAMPLE_RATE);
138133 }
139134
140135 if (showR)
0 commit comments