Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem_Copy_of_mbed_version I2S
NotchingDemo.cpp@65:8b6a4e307941, 2019-09-29 (annotated)
- Committer:
- roryhand
- Date:
- Sun Sep 29 19:58:24 2019 +0000
- Branch:
- LargeFile_Tests
- Revision:
- 65:8b6a4e307941
- Parent:
- 64:6061ffe25985
- Child:
- 66:edf370edd21c
WIP - Added in a new class: classFade
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
roryhand | 1:aac37edee302 | 1 | |
roryhand | 0:e89d7a0bfa3b | 2 | // 24/03/2018 update - I appear to be able to address the device and write something, as I am getting an ACK returned from the i2c write() function. |
roryhand | 0:e89d7a0bfa3b | 3 | //however if i use the write function with 4 arguments (as opposed to just 1 argument) then it doesnt work |
roryhand | 0:e89d7a0bfa3b | 4 | //only works with the 1 argument version!!! |
roryhand | 0:e89d7a0bfa3b | 5 | |
roryhand | 0:e89d7a0bfa3b | 6 | |
roryhand | 0:e89d7a0bfa3b | 7 | //THIS VERSION WORKED, CHANGED SOME THINGS, THEN CHANGED THEM BACK. NOW IT NO LONGER WORKS!!!! |
roryhand | 0:e89d7a0bfa3b | 8 | #include "mbed.h" |
roryhand | 0:e89d7a0bfa3b | 9 | #include "math.h" |
roryhand | 1:aac37edee302 | 10 | #include "I2S.h" |
roryhand | 1:aac37edee302 | 11 | #include "SDFileSystem.h" |
roryhand | 0:e89d7a0bfa3b | 12 | #include "wm8731_Config_setup.h" |
roryhand | 0:e89d7a0bfa3b | 13 | #include "WOLFSON_config_consts.h" |
roryhand | 54:606a83fff291 | 14 | //#include "BlockDevice.h" |
roryhand | 37:a563899ac0df | 15 | #include <string> |
roryhand | 0:e89d7a0bfa3b | 16 | #include <stdlib.h> |
roryhand | 27:a378f1f937ee | 17 | #include <fstream> |
roryhand | 27:a378f1f937ee | 18 | #include <iostream> |
roryhand | 0:e89d7a0bfa3b | 19 | #include <vector> |
roryhand | 0:e89d7a0bfa3b | 20 | #include <string> |
roryhand | 0:e89d7a0bfa3b | 21 | #define sample_freq 11025 |
roryhand | 1:aac37edee302 | 22 | #pragma import __use_two_region_memory |
roryhand | 54:606a83fff291 | 23 | //BlockDevice *bd = BlockDevice::get_default_instance(); |
roryhand | 54:606a83fff291 | 24 | //#include "LittleFileSystem.h" |
roryhand | 54:606a83fff291 | 25 | //LittleFileSystem fs("fs"); |
roryhand | 54:606a83fff291 | 26 | |
roryhand | 0:e89d7a0bfa3b | 27 | DigitalOut myled(LED1); |
roryhand | 0:e89d7a0bfa3b | 28 | DigitalOut led2(LED2); |
roryhand | 0:e89d7a0bfa3b | 29 | DigitalOut led3(LED3); |
roryhand | 0:e89d7a0bfa3b | 30 | DigitalIn NotchUp(p16); |
roryhand | 38:3b4c05af5f36 | 31 | DigitalIn NotchDown(p17);//check the pin!!! Dont know if this will actually work... |
roryhand | 0:e89d7a0bfa3b | 32 | InterruptIn Horn(p16); |
roryhand | 0:e89d7a0bfa3b | 33 | Ticker sampletick; |
roryhand | 45:0e8e1f2ec5d2 | 34 | |
roryhand | 0:e89d7a0bfa3b | 35 | Ticker TickFadeOut; |
roryhand | 0:e89d7a0bfa3b | 36 | Timer t; |
roryhand | 0:e89d7a0bfa3b | 37 | Timer t2; |
roryhand | 3:6169aeeaeeb4 | 38 | Timer NotchTimer; |
roryhand | 27:a378f1f937ee | 39 | Timer timer_open; |
roryhand | 0:e89d7a0bfa3b | 40 | |
roryhand | 0:e89d7a0bfa3b | 41 | Serial pc(USBTX, USBRX); // tx, rx //FOR DEBUGGING PROGRAM USING GNU SCREEN |
roryhand | 0:e89d7a0bfa3b | 42 | DigitalOut cs(p8); |
roryhand | 0:e89d7a0bfa3b | 43 | I2S i2s(I2S_TRANSMIT, p5, p6, p7); |
roryhand | 0:e89d7a0bfa3b | 44 | SDFileSystem sd(p11, p12, p13, p8, "sd"); // the new pinout that i am using |
roryhand | 0:e89d7a0bfa3b | 45 | |
roryhand | 65:8b6a4e307941 | 46 | class classFade |
roryhand | 65:8b6a4e307941 | 47 | { |
roryhand | 65:8b6a4e307941 | 48 | public: |
roryhand | 65:8b6a4e307941 | 49 | |
roryhand | 65:8b6a4e307941 | 50 | float powerval; |
roryhand | 65:8b6a4e307941 | 51 | float FadeIteration; |
roryhand | 65:8b6a4e307941 | 52 | float DecayFactor; |
roryhand | 65:8b6a4e307941 | 53 | float Denom; |
roryhand | 65:8b6a4e307941 | 54 | float FadeCoeff; |
roryhand | 65:8b6a4e307941 | 55 | float Natural_Exp; |
roryhand | 65:8b6a4e307941 | 56 | int LengthSecs; |
roryhand | 65:8b6a4e307941 | 57 | int Length; |
roryhand | 65:8b6a4e307941 | 58 | |
roryhand | 65:8b6a4e307941 | 59 | //member Functions |
roryhand | 65:8b6a4e307941 | 60 | float FadeOut(void) |
roryhand | 65:8b6a4e307941 | 61 | { |
roryhand | 65:8b6a4e307941 | 62 | powerval = -FadeIteration/Denom; |
roryhand | 65:8b6a4e307941 | 63 | if (FadeIteration >=Length) { |
roryhand | 65:8b6a4e307941 | 64 | FadeCoeff = 0; |
roryhand | 65:8b6a4e307941 | 65 | |
roryhand | 65:8b6a4e307941 | 66 | } else { |
roryhand | 65:8b6a4e307941 | 67 | FadeCoeff = (Length - FadeIteration)/Length; |
roryhand | 65:8b6a4e307941 | 68 | } |
roryhand | 65:8b6a4e307941 | 69 | FadeIteration = FadeIteration + 1; |
roryhand | 65:8b6a4e307941 | 70 | return FadeCoeff; |
roryhand | 65:8b6a4e307941 | 71 | |
roryhand | 65:8b6a4e307941 | 72 | } |
roryhand | 65:8b6a4e307941 | 73 | float FadeIn(void) |
roryhand | 65:8b6a4e307941 | 74 | { |
roryhand | 65:8b6a4e307941 | 75 | powerval = FadeIteration/Denom; |
roryhand | 65:8b6a4e307941 | 76 | if (FadeIteration >=Length) { |
roryhand | 65:8b6a4e307941 | 77 | FadeCoeff = 1; |
roryhand | 65:8b6a4e307941 | 78 | |
roryhand | 65:8b6a4e307941 | 79 | } else { |
roryhand | 65:8b6a4e307941 | 80 | FadeCoeff = FadeIteration/Length; |
roryhand | 65:8b6a4e307941 | 81 | } |
roryhand | 65:8b6a4e307941 | 82 | |
roryhand | 65:8b6a4e307941 | 83 | FadeIteration = FadeIteration + 1; |
roryhand | 65:8b6a4e307941 | 84 | return FadeCoeff; |
roryhand | 65:8b6a4e307941 | 85 | |
roryhand | 65:8b6a4e307941 | 86 | } |
roryhand | 65:8b6a4e307941 | 87 | }; |
roryhand | 65:8b6a4e307941 | 88 | |
roryhand | 65:8b6a4e307941 | 89 | |
roryhand | 1:aac37edee302 | 90 | typedef struct uFMT_STRUCT { |
roryhand | 1:aac37edee302 | 91 | short comp_code; |
roryhand | 1:aac37edee302 | 92 | short num_channels; |
roryhand | 1:aac37edee302 | 93 | unsigned sample_rate; |
roryhand | 1:aac37edee302 | 94 | unsigned avg_Bps; |
roryhand | 1:aac37edee302 | 95 | short block_align; |
roryhand | 1:aac37edee302 | 96 | short sig_bps; |
roryhand | 0:e89d7a0bfa3b | 97 | } FMT_STRUCT; |
roryhand | 0:e89d7a0bfa3b | 98 | |
roryhand | 1:aac37edee302 | 99 | typedef struct uNotch_STRUCT { |
roryhand | 1:aac37edee302 | 100 | short Notch; |
roryhand | 1:aac37edee302 | 101 | short NotchTransUp; |
roryhand | 1:aac37edee302 | 102 | short NotchTransDown; |
roryhand | 1:aac37edee302 | 103 | short NotchDirection; |
roryhand | 1:aac37edee302 | 104 | } Notch_STRUCT; |
roryhand | 1:aac37edee302 | 105 | |
roryhand | 0:e89d7a0bfa3b | 106 | typedef struct uDATA_STRUCT { |
roryhand | 1:aac37edee302 | 107 | unsigned subchunk2_ID; |
roryhand | 1:aac37edee302 | 108 | unsigned subchunk2_size; |
roryhand | 1:aac37edee302 | 109 | char * data_buf; |
roryhand | 1:aac37edee302 | 110 | } DATA_STRUCT; |
roryhand | 0:e89d7a0bfa3b | 111 | |
roryhand | 1:aac37edee302 | 112 | typedef struct uWAV_FILE_STRUCT { |
roryhand | 1:aac37edee302 | 113 | FILE *WavFile; |
roryhand | 1:aac37edee302 | 114 | int id_number; |
roryhand | 1:aac37edee302 | 115 | char *slice_buf; |
roryhand | 1:aac37edee302 | 116 | int num_slices; |
roryhand | 1:aac37edee302 | 117 | FMT_STRUCT FileFormat; |
roryhand | 1:aac37edee302 | 118 | DATA_STRUCT FileData; |
roryhand | 0:e89d7a0bfa3b | 119 | } WAV_FILE_STRUCT; |
roryhand | 0:e89d7a0bfa3b | 120 | |
roryhand | 0:e89d7a0bfa3b | 121 | /*typedef struct uWAV_FILE_STRUCT{ |
roryhand | 1:aac37edee302 | 122 | FILE* WavFile; |
roryhand | 1:aac37edee302 | 123 | |
roryhand | 1:aac37edee302 | 124 | |
roryhand | 0:e89d7a0bfa3b | 125 | }WAV_FILE_STRUCT;*/ |
roryhand | 59:8e7c25a915a0 | 126 | |
roryhand | 59:8e7c25a915a0 | 127 | |
roryhand | 59:8e7c25a915a0 | 128 | |
roryhand | 59:8e7c25a915a0 | 129 | |
roryhand | 59:8e7c25a915a0 | 130 | |
roryhand | 59:8e7c25a915a0 | 131 | class classSoundFile |
roryhand | 59:8e7c25a915a0 | 132 | { |
roryhand | 59:8e7c25a915a0 | 133 | public: |
roryhand | 59:8e7c25a915a0 | 134 | |
roryhand | 59:8e7c25a915a0 | 135 | //add a class constructor at some point in the future (perform tests in visual studio) |
roryhand | 59:8e7c25a915a0 | 136 | WAV_FILE_STRUCT FileInfo; |
roryhand | 59:8e7c25a915a0 | 137 | short * data_sptr; |
roryhand | 59:8e7c25a915a0 | 138 | string file_location; |
roryhand | 59:8e7c25a915a0 | 139 | //classSoundFile(string filename);//this is the constructor |
roryhand | 59:8e7c25a915a0 | 140 | //string filename; |
roryhand | 59:8e7c25a915a0 | 141 | }; |
roryhand | 58:a174e7a8f5f2 | 142 | class classPositionIndicators |
roryhand | 57:0c76b15cabaf | 143 | { |
roryhand | 57:0c76b15cabaf | 144 | public: |
roryhand | 57:0c76b15cabaf | 145 | int notch1_indicator, notch2_indicator, notch3_indicator, notch4_indicator; |
roryhand | 57:0c76b15cabaf | 146 | int notch5_indicator, notch6_indicator, notch7_indicator, notch8_indicator; |
roryhand | 57:0c76b15cabaf | 147 | int notch1_start_pt, notch2_start_pt, notch3_start_pt, notch4_start_pt; |
roryhand | 57:0c76b15cabaf | 148 | int notch5_start_pt, notch6_start_pt, notch7_start_pt, notch8_start_pt; |
roryhand | 63:a8c1971d3d42 | 149 | int N1N2_start_pt, N2N3_start_pt, N3N4_start_pt, N4N5_start_pt, N5N6_start_pt; |
roryhand | 63:a8c1971d3d42 | 150 | int N6N7_start_pt, N7N8_start_pt, N8N7_start_pt, N7N6_start_pt, N6N5_start_pt; |
roryhand | 63:a8c1971d3d42 | 151 | int N5N4_start_pt, N4N3_start_pt, N3N2_start_pt, N2N1_start_pt; |
roryhand | 63:a8c1971d3d42 | 152 | |
roryhand | 61:212d2db45c56 | 153 | int notch_start_pts [9]; |
roryhand | 61:212d2db45c56 | 154 | int notch_position_indicators[9]; |
roryhand | 61:212d2db45c56 | 155 | int notch_transitions_start_pts[15]; |
roryhand | 61:212d2db45c56 | 156 | int notch_transitions_position_indicators[15]; |
roryhand | 61:212d2db45c56 | 157 | int auxiliary_start_pts[5]; |
roryhand | 61:212d2db45c56 | 158 | int auxiliary_position_indicators[5]; |
roryhand | 58:a174e7a8f5f2 | 159 | classPositionIndicators() |
roryhand | 57:0c76b15cabaf | 160 | { |
roryhand | 57:0c76b15cabaf | 161 | notch1_start_pt = 44; |
roryhand | 57:0c76b15cabaf | 162 | notch2_start_pt = 220884+44; |
roryhand | 57:0c76b15cabaf | 163 | notch3_start_pt = notch2_start_pt+217698; |
roryhand | 57:0c76b15cabaf | 164 | notch4_start_pt = notch3_start_pt + 193060; |
roryhand | 57:0c76b15cabaf | 165 | notch5_start_pt = notch4_start_pt + 92010; |
roryhand | 57:0c76b15cabaf | 166 | notch6_start_pt = notch5_start_pt + 216642; |
roryhand | 57:0c76b15cabaf | 167 | notch7_start_pt = notch6_start_pt + 250316; |
roryhand | 61:212d2db45c56 | 168 | notch8_start_pt = notch7_start_pt + 150152; |
roryhand | 57:0c76b15cabaf | 169 | notch1_indicator = notch1_start_pt; |
roryhand | 57:0c76b15cabaf | 170 | notch2_indicator = notch2_start_pt; |
roryhand | 57:0c76b15cabaf | 171 | notch3_indicator = notch3_start_pt; |
roryhand | 57:0c76b15cabaf | 172 | notch4_indicator = notch4_start_pt; |
roryhand | 57:0c76b15cabaf | 173 | notch5_indicator = notch5_start_pt; |
roryhand | 57:0c76b15cabaf | 174 | notch6_indicator = notch6_start_pt; |
roryhand | 57:0c76b15cabaf | 175 | notch7_indicator = notch7_start_pt; |
roryhand | 57:0c76b15cabaf | 176 | notch8_indicator = notch8_start_pt; |
roryhand | 61:212d2db45c56 | 177 | notch_start_pts[1] = notch1_start_pt; |
roryhand | 61:212d2db45c56 | 178 | notch_start_pts[2] = notch2_start_pt; |
roryhand | 61:212d2db45c56 | 179 | notch_start_pts[3] = notch3_start_pt; |
roryhand | 61:212d2db45c56 | 180 | notch_start_pts[4] = notch4_start_pt; |
roryhand | 61:212d2db45c56 | 181 | notch_start_pts[5] = notch5_start_pt; |
roryhand | 61:212d2db45c56 | 182 | notch_start_pts[6] = notch6_start_pt; |
roryhand | 61:212d2db45c56 | 183 | notch_start_pts[7] = notch7_start_pt; |
roryhand | 61:212d2db45c56 | 184 | notch_start_pts[8] = notch8_start_pt; |
roryhand | 61:212d2db45c56 | 185 | notch_position_indicators[1] = notch1_indicator; |
roryhand | 61:212d2db45c56 | 186 | notch_position_indicators[2] = notch2_indicator; |
roryhand | 61:212d2db45c56 | 187 | notch_position_indicators[3] = notch3_indicator; |
roryhand | 61:212d2db45c56 | 188 | notch_position_indicators[4] = notch4_indicator; |
roryhand | 61:212d2db45c56 | 189 | notch_position_indicators[5] = notch5_indicator; |
roryhand | 61:212d2db45c56 | 190 | notch_position_indicators[6] = notch6_indicator; |
roryhand | 61:212d2db45c56 | 191 | notch_position_indicators[7] = notch7_indicator; |
roryhand | 61:212d2db45c56 | 192 | notch_position_indicators[8] = notch8_indicator; |
roryhand | 63:a8c1971d3d42 | 193 | |
roryhand | 63:a8c1971d3d42 | 194 | N1N2_start_pt = 44; |
roryhand | 63:a8c1971d3d42 | 195 | N2N3_start_pt = N1N2_start_pt + 73220; |
roryhand | 63:a8c1971d3d42 | 196 | N3N4_start_pt = N2N3_start_pt + 78164; |
roryhand | 63:a8c1971d3d42 | 197 | N4N5_start_pt = N3N4_start_pt + 59432; |
roryhand | 63:a8c1971d3d42 | 198 | N5N6_start_pt = N4N5_start_pt + 64984; |
roryhand | 63:a8c1971d3d42 | 199 | N6N7_start_pt = N5N6_start_pt + 59924; |
roryhand | 63:a8c1971d3d42 | 200 | N7N8_start_pt = N6N7_start_pt + 97874; |
roryhand | 63:a8c1971d3d42 | 201 | N8N7_start_pt = N7N8_start_pt + 63992; |
roryhand | 63:a8c1971d3d42 | 202 | N7N6_start_pt = N8N7_start_pt + 44506; |
roryhand | 63:a8c1971d3d42 | 203 | N6N5_start_pt = N7N6_start_pt + 55052; |
roryhand | 63:a8c1971d3d42 | 204 | N5N4_start_pt = N6N5_start_pt + 37038; |
roryhand | 63:a8c1971d3d42 | 205 | N4N3_start_pt = N5N4_start_pt + 49692; |
roryhand | 63:a8c1971d3d42 | 206 | N3N2_start_pt = N4N3_start_pt + 44100; |
roryhand | 63:a8c1971d3d42 | 207 | N2N1_start_pt = N3N2_start_pt + 58346; |
roryhand | 63:a8c1971d3d42 | 208 | |
roryhand | 63:a8c1971d3d42 | 209 | |
roryhand | 63:a8c1971d3d42 | 210 | notch_transitions_start_pts[1] = N1N2_start_pt; |
roryhand | 63:a8c1971d3d42 | 211 | notch_transitions_start_pts[2] = N2N3_start_pt; |
roryhand | 63:a8c1971d3d42 | 212 | notch_transitions_start_pts[3] = N3N4_start_pt; |
roryhand | 63:a8c1971d3d42 | 213 | notch_transitions_start_pts[4] = N4N5_start_pt; |
roryhand | 63:a8c1971d3d42 | 214 | notch_transitions_start_pts[5] = N5N6_start_pt; |
roryhand | 63:a8c1971d3d42 | 215 | notch_transitions_start_pts[6] = N6N7_start_pt; |
roryhand | 63:a8c1971d3d42 | 216 | notch_transitions_start_pts[7] = N7N8_start_pt; |
roryhand | 63:a8c1971d3d42 | 217 | notch_transitions_start_pts[8] = N8N7_start_pt; |
roryhand | 63:a8c1971d3d42 | 218 | notch_transitions_start_pts[9] = N7N6_start_pt; |
roryhand | 63:a8c1971d3d42 | 219 | notch_transitions_start_pts[10] = N6N5_start_pt; |
roryhand | 63:a8c1971d3d42 | 220 | notch_transitions_start_pts[11] = N5N4_start_pt; |
roryhand | 63:a8c1971d3d42 | 221 | notch_transitions_start_pts[12] = N4N3_start_pt; |
roryhand | 63:a8c1971d3d42 | 222 | notch_transitions_start_pts[13] = N3N2_start_pt; |
roryhand | 63:a8c1971d3d42 | 223 | notch_transitions_start_pts[14] = N2N1_start_pt; |
roryhand | 63:a8c1971d3d42 | 224 | |
roryhand | 63:a8c1971d3d42 | 225 | |
roryhand | 63:a8c1971d3d42 | 226 | notch_transitions_position_indicators[1] = N1N2_start_pt; |
roryhand | 63:a8c1971d3d42 | 227 | notch_transitions_position_indicators[2] = N2N3_start_pt; |
roryhand | 63:a8c1971d3d42 | 228 | notch_transitions_position_indicators[3] = N3N4_start_pt; |
roryhand | 63:a8c1971d3d42 | 229 | notch_transitions_position_indicators[4] = N4N5_start_pt; |
roryhand | 63:a8c1971d3d42 | 230 | notch_transitions_position_indicators[5] = N5N6_start_pt; |
roryhand | 63:a8c1971d3d42 | 231 | notch_transitions_position_indicators[6] = N6N7_start_pt; |
roryhand | 63:a8c1971d3d42 | 232 | notch_transitions_position_indicators[7] = N7N8_start_pt; |
roryhand | 63:a8c1971d3d42 | 233 | notch_transitions_position_indicators[8] = N8N7_start_pt; |
roryhand | 63:a8c1971d3d42 | 234 | notch_transitions_position_indicators[9] = N7N6_start_pt; |
roryhand | 63:a8c1971d3d42 | 235 | notch_transitions_position_indicators[10] = N6N5_start_pt; |
roryhand | 63:a8c1971d3d42 | 236 | notch_transitions_position_indicators[11] = N5N4_start_pt; |
roryhand | 63:a8c1971d3d42 | 237 | notch_transitions_position_indicators[12] = N4N3_start_pt; |
roryhand | 63:a8c1971d3d42 | 238 | notch_transitions_position_indicators[13] = N3N2_start_pt; |
roryhand | 63:a8c1971d3d42 | 239 | notch_transitions_position_indicators[14] = N2N1_start_pt; |
roryhand | 57:0c76b15cabaf | 240 | } |
roryhand | 57:0c76b15cabaf | 241 | }; |
roryhand | 57:0c76b15cabaf | 242 | |
roryhand | 54:606a83fff291 | 243 | int OneOff = 0; |
roryhand | 38:3b4c05af5f36 | 244 | int notch_flag = 0; |
roryhand | 0:e89d7a0bfa3b | 245 | int i = 0; |
roryhand | 0:e89d7a0bfa3b | 246 | int h = 0; |
roryhand | 0:e89d7a0bfa3b | 247 | short bufflen = 1; |
roryhand | 0:e89d7a0bfa3b | 248 | int buffer[1]; |
roryhand | 1:aac37edee302 | 249 | int AudioFormat, NumChannels, SampleRate, BitsPerSample ; |
roryhand | 0:e89d7a0bfa3b | 250 | char *slice_buf; |
roryhand | 0:e89d7a0bfa3b | 251 | short *data_sptr; |
roryhand | 0:e89d7a0bfa3b | 252 | short *data_sptr_horn; |
roryhand | 0:e89d7a0bfa3b | 253 | short *data_sptr_IdleN2; |
roryhand | 0:e89d7a0bfa3b | 254 | short * data_sptr_bell; |
roryhand | 0:e89d7a0bfa3b | 255 | short * data_sptr_N2; |
roryhand | 0:e89d7a0bfa3b | 256 | short * data_sptr_Flange; |
roryhand | 0:e89d7a0bfa3b | 257 | unsigned char *data_bptr; |
roryhand | 0:e89d7a0bfa3b | 258 | int *data_wptr; |
roryhand | 0:e89d7a0bfa3b | 259 | unsigned channel; |
roryhand | 45:0e8e1f2ec5d2 | 260 | long slice, slice1, slice2, slice3, num_slices; |
roryhand | 0:e89d7a0bfa3b | 261 | int verbosity = 0; |
roryhand | 0:e89d7a0bfa3b | 262 | int verbosity2 = 0; |
roryhand | 0:e89d7a0bfa3b | 263 | int verbosity3 = 0; |
roryhand | 0:e89d7a0bfa3b | 264 | int verbosity4 = 0; |
roryhand | 0:e89d7a0bfa3b | 265 | int verbosity5 = 0; |
roryhand | 0:e89d7a0bfa3b | 266 | int interrupt_condition = 1; |
roryhand | 0:e89d7a0bfa3b | 267 | int sampling_freq = 11025; |
roryhand | 0:e89d7a0bfa3b | 268 | const int BufferLen = 2000; |
roryhand | 0:e89d7a0bfa3b | 269 | short Buffer1[BufferLen]; |
roryhand | 0:e89d7a0bfa3b | 270 | short Buffer2[BufferLen]; |
roryhand | 0:e89d7a0bfa3b | 271 | short place_hold1 = 0; |
roryhand | 0:e89d7a0bfa3b | 272 | short place_hold2 = 0; |
roryhand | 0:e89d7a0bfa3b | 273 | |
roryhand | 3:6169aeeaeeb4 | 274 | |
roryhand | 3:6169aeeaeeb4 | 275 | string FOLDER; |
roryhand | 3:6169aeeaeeb4 | 276 | string RootFolder = "/sd/mydir/SoundDecoder/"; |
roryhand | 3:6169aeeaeeb4 | 277 | string filename[25]; |
roryhand | 3:6169aeeaeeb4 | 278 | classSoundFile Sound[22]; |
roryhand | 3:6169aeeaeeb4 | 279 | |
roryhand | 0:e89d7a0bfa3b | 280 | volatile int flag1 = 1; |
roryhand | 0:e89d7a0bfa3b | 281 | volatile int flag2 = 0; |
roryhand | 0:e89d7a0bfa3b | 282 | volatile int flag3 = 1; |
roryhand | 0:e89d7a0bfa3b | 283 | volatile int flag4 = 0; |
roryhand | 0:e89d7a0bfa3b | 284 | int FLAGBUFF1 = 0; |
roryhand | 0:e89d7a0bfa3b | 285 | int FLAGBUFF2 = 0; |
roryhand | 0:e89d7a0bfa3b | 286 | int BellFlag = 0; |
roryhand | 0:e89d7a0bfa3b | 287 | int BellFlag2 = 0; |
roryhand | 0:e89d7a0bfa3b | 288 | int FadeFlag = 0; |
roryhand | 54:606a83fff291 | 289 | int BlockFlag = 0; |
roryhand | 32:6ee488c97dcc | 290 | int FileSwitchFlag = 0; |
roryhand | 0:e89d7a0bfa3b | 291 | |
roryhand | 0:e89d7a0bfa3b | 292 | |
roryhand | 0:e89d7a0bfa3b | 293 | short value[1]; |
roryhand | 59:8e7c25a915a0 | 294 | |
roryhand | 0:e89d7a0bfa3b | 295 | //long long slice_value; |
roryhand | 0:e89d7a0bfa3b | 296 | int slice_value[1]; |
roryhand | 0:e89d7a0bfa3b | 297 | |
roryhand | 0:e89d7a0bfa3b | 298 | |
roryhand | 45:0e8e1f2ec5d2 | 299 | FILE *wavfile1; |
roryhand | 45:0e8e1f2ec5d2 | 300 | FILE *wavfile2; |
roryhand | 45:0e8e1f2ec5d2 | 301 | FILE *wavfile3; |
roryhand | 45:0e8e1f2ec5d2 | 302 | |
roryhand | 45:0e8e1f2ec5d2 | 303 | classSoundFile Sound1; |
roryhand | 45:0e8e1f2ec5d2 | 304 | classSoundFile Sound2; |
roryhand | 45:0e8e1f2ec5d2 | 305 | classSoundFile Sound3; |
roryhand | 45:0e8e1f2ec5d2 | 306 | |
roryhand | 0:e89d7a0bfa3b | 307 | |
roryhand | 0:e89d7a0bfa3b | 308 | void isr() |
roryhand | 0:e89d7a0bfa3b | 309 | { |
roryhand | 54:606a83fff291 | 310 | //timer_interrupt.start(); |
roryhand | 1:aac37edee302 | 311 | if(flag1 == 0) { |
roryhand | 0:e89d7a0bfa3b | 312 | value[0] = Buffer1[place_hold1]>>4; |
roryhand | 0:e89d7a0bfa3b | 313 | i2s.write(value,1);//Send next PWM value to amp |
roryhand | 0:e89d7a0bfa3b | 314 | place_hold1 = place_hold1 + 1; |
roryhand | 1:aac37edee302 | 315 | if( (place_hold1 >= BufferLen)) { |
roryhand | 0:e89d7a0bfa3b | 316 | led2 = !led2; |
roryhand | 0:e89d7a0bfa3b | 317 | place_hold1 = 0; |
roryhand | 0:e89d7a0bfa3b | 318 | place_hold2 = 0; |
roryhand | 0:e89d7a0bfa3b | 319 | flag1 = 1; |
roryhand | 0:e89d7a0bfa3b | 320 | flag2 = 0; |
roryhand | 1:aac37edee302 | 321 | } |
roryhand | 1:aac37edee302 | 322 | } else if(flag2 == 0) { |
roryhand | 0:e89d7a0bfa3b | 323 | value[0] = Buffer2[place_hold2]>>4; |
roryhand | 0:e89d7a0bfa3b | 324 | i2s.write(value,1);//Send next PWM value to amp |
roryhand | 0:e89d7a0bfa3b | 325 | place_hold2 = place_hold2 + 1; |
roryhand | 1:aac37edee302 | 326 | if( (place_hold2 >= BufferLen) ) { |
roryhand | 0:e89d7a0bfa3b | 327 | led2 = !led2; |
roryhand | 0:e89d7a0bfa3b | 328 | place_hold1 = 0; |
roryhand | 0:e89d7a0bfa3b | 329 | place_hold2 = 0; |
roryhand | 0:e89d7a0bfa3b | 330 | flag1 = 0; |
roryhand | 1:aac37edee302 | 331 | flag2 = 1; |
roryhand | 0:e89d7a0bfa3b | 332 | FLAGBUFF2 = 0; |
roryhand | 1:aac37edee302 | 333 | } |
roryhand | 0:e89d7a0bfa3b | 334 | } |
roryhand | 54:606a83fff291 | 335 | |
roryhand | 54:606a83fff291 | 336 | //timer_interrupt.stop(); |
roryhand | 54:606a83fff291 | 337 | |
roryhand | 0:e89d7a0bfa3b | 338 | } |
roryhand | 1:aac37edee302 | 339 | |
roryhand | 38:3b4c05af5f36 | 340 | |
roryhand | 38:3b4c05af5f36 | 341 | |
roryhand | 38:3b4c05af5f36 | 342 | |
roryhand | 38:3b4c05af5f36 | 343 | |
roryhand | 0:e89d7a0bfa3b | 344 | |
roryhand | 59:8e7c25a915a0 | 345 | |
roryhand | 59:8e7c25a915a0 | 346 | |
roryhand | 59:8e7c25a915a0 | 347 | |
roryhand | 59:8e7c25a915a0 | 348 | |
roryhand | 59:8e7c25a915a0 | 349 | |
roryhand | 3:6169aeeaeeb4 | 350 | |
roryhand | 3:6169aeeaeeb4 | 351 | |
roryhand | 3:6169aeeaeeb4 | 352 | |
roryhand | 3:6169aeeaeeb4 | 353 | |
roryhand | 3:6169aeeaeeb4 | 354 | |
roryhand | 3:6169aeeaeeb4 | 355 | //function prototypes |
roryhand | 45:0e8e1f2ec5d2 | 356 | classSoundFile ReadFileInfo(classSoundFile Sound, FILE * wav_file); |
roryhand | 3:6169aeeaeeb4 | 357 | classSoundFile LoadFileStream(classSoundFile FileInfo, string filename); |
roryhand | 3:6169aeeaeeb4 | 358 | void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo); |
roryhand | 32:6ee488c97dcc | 359 | void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo); |
roryhand | 59:8e7c25a915a0 | 360 | void Play_WaveFileLoop(classSoundFile Sound1, FILE* wavfile1,classPositionIndicators Positions); |
roryhand | 0:e89d7a0bfa3b | 361 | |
roryhand | 1:aac37edee302 | 362 | int main() |
roryhand | 1:aac37edee302 | 363 | { |
roryhand | 44:a9e84d333a6a | 364 | |
roryhand | 0:e89d7a0bfa3b | 365 | NotchUp.mode(PullUp); |
roryhand | 38:3b4c05af5f36 | 366 | NotchDown.mode(PullUp); |
roryhand | 0:e89d7a0bfa3b | 367 | |
roryhand | 0:e89d7a0bfa3b | 368 | pc.printf("Beginning of program\n"); |
roryhand | 32:6ee488c97dcc | 369 | |
roryhand | 13:8e93396a27c5 | 370 | |
roryhand | 13:8e93396a27c5 | 371 | |
roryhand | 4:55fbbb049bae | 372 | |
roryhand | 25:5336e1cf38d6 | 373 | printf("Do we even get to this stupid bloody point\n\r"); |
roryhand | 0:e89d7a0bfa3b | 374 | //Populate our class instances with some data (is there an implicit way to do this?) |
roryhand | 28:6b2353fad12d | 375 | |
roryhand | 1:aac37edee302 | 376 | |
roryhand | 3:6169aeeaeeb4 | 377 | printf("hello\n\r"); |
roryhand | 0:e89d7a0bfa3b | 378 | //Set up the wolfson Audio Codec board |
roryhand | 0:e89d7a0bfa3b | 379 | wm8731_Config_setup(); |
roryhand | 0:e89d7a0bfa3b | 380 | //i2s audio data transfer code?? |
roryhand | 0:e89d7a0bfa3b | 381 | i2s.stereomono(I2S_STEREO); |
roryhand | 0:e89d7a0bfa3b | 382 | i2s.masterslave(I2S_MASTER); |
roryhand | 0:e89d7a0bfa3b | 383 | led3 = 1; |
roryhand | 0:e89d7a0bfa3b | 384 | led2 = 1; |
roryhand | 45:0e8e1f2ec5d2 | 385 | printf("Hello i2s has started!"); |
roryhand | 30:4a8e80b243c4 | 386 | i2s.start(); |
roryhand | 0:e89d7a0bfa3b | 387 | sampletick.attach(&isr,1.0/sampling_freq); //1/16000 |
roryhand | 54:606a83fff291 | 388 | |
roryhand | 58:a174e7a8f5f2 | 389 | classPositionIndicators Positions; |
roryhand | 61:212d2db45c56 | 390 | slice1 = Positions.notch7_start_pt; |
roryhand | 60:36df2997de3d | 391 | FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb"); |
roryhand | 60:36df2997de3d | 392 | //FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb"); |
roryhand | 58:a174e7a8f5f2 | 393 | classSoundFile Sound1; |
roryhand | 58:a174e7a8f5f2 | 394 | Sound1 = ReadFileInfo(Sound1, wavfile1); |
roryhand | 61:212d2db45c56 | 395 | fseek(wavfile1,Positions.notch7_start_pt,SEEK_SET); |
roryhand | 20:9cc7d825c07b | 396 | printf("about to play wav file\n\r"); |
roryhand | 59:8e7c25a915a0 | 397 | Play_WaveFileLoop(Sound1,wavfile1,Positions); |
roryhand | 20:9cc7d825c07b | 398 | printf("finished playing Wav file\n\r"); |
roryhand | 54:606a83fff291 | 399 | |
roryhand | 54:606a83fff291 | 400 | |
roryhand | 31:0f8c3adf09c3 | 401 | timer_open.reset(); |
roryhand | 31:0f8c3adf09c3 | 402 | timer_open.start(); |
roryhand | 45:0e8e1f2ec5d2 | 403 | fclose(wavfile1); |
roryhand | 31:0f8c3adf09c3 | 404 | timer_open.stop(); |
roryhand | 31:0f8c3adf09c3 | 405 | printf("It took %d useconds to close file\n\r",timer_open.read_us()); |
roryhand | 54:606a83fff291 | 406 | |
roryhand | 54:606a83fff291 | 407 | |
roryhand | 54:606a83fff291 | 408 | |
roryhand | 54:606a83fff291 | 409 | |
roryhand | 9:dd9cae06b202 | 410 | /************************************PLAY WAV FILE LOOP*******************/ |
roryhand | 9:dd9cae06b202 | 411 | /************************************END OF PLAY WAV FILE LOOP*************/ |
roryhand | 13:8e93396a27c5 | 412 | |
roryhand | 13:8e93396a27c5 | 413 | |
roryhand | 1:aac37edee302 | 414 | i2s.stop(); |
roryhand | 0:e89d7a0bfa3b | 415 | |
roryhand | 0:e89d7a0bfa3b | 416 | } |
roryhand | 0:e89d7a0bfa3b | 417 | |
roryhand | 0:e89d7a0bfa3b | 418 | |
roryhand | 3:6169aeeaeeb4 | 419 | |
roryhand | 3:6169aeeaeeb4 | 420 | |
roryhand | 3:6169aeeaeeb4 | 421 | |
roryhand | 3:6169aeeaeeb4 | 422 | |
roryhand | 45:0e8e1f2ec5d2 | 423 | classSoundFile ReadFileInfo(classSoundFile Sound, FILE * wav_file) |
roryhand | 0:e89d7a0bfa3b | 424 | { |
roryhand | 0:e89d7a0bfa3b | 425 | fseek(wav_file,20,SEEK_SET); |
roryhand | 22:706e86dc0d45 | 426 | printf("We have just seeked through this file\n\r"); |
roryhand | 45:0e8e1f2ec5d2 | 427 | fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,wav_file); |
roryhand | 1:aac37edee302 | 428 | //printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate); |
roryhand | 1:aac37edee302 | 429 | |
roryhand | 45:0e8e1f2ec5d2 | 430 | fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,wav_file); |
roryhand | 55:5a441d3b0d57 | 431 | printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size); |
roryhand | 45:0e8e1f2ec5d2 | 432 | Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align); |
roryhand | 59:8e7c25a915a0 | 433 | printf("Wav File Block Align (number of bytes per sample!!: %d\n\r", Sound.FileInfo.FileFormat.block_align); |
roryhand | 45:0e8e1f2ec5d2 | 434 | fread(Sound.FileInfo.slice_buf,Sound.FileInfo.FileFormat.block_align,1,wav_file); //This isnt actually required, its just a test |
roryhand | 45:0e8e1f2ec5d2 | 435 | Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align; |
roryhand | 1:aac37edee302 | 436 | //printf("Number of Slices: %d\n\r",FileInfo.num_slices); |
roryhand | 45:0e8e1f2ec5d2 | 437 | return Sound; |
roryhand | 0:e89d7a0bfa3b | 438 | } |
roryhand | 1:aac37edee302 | 439 | |
roryhand | 1:aac37edee302 | 440 | |
roryhand | 64:6061ffe25985 | 441 | //Function to initialise Data for classFade objects. Perhaps move this into a constructor for the class? (class still to be added) |
roryhand | 64:6061ffe25985 | 442 | classFade FadeDataInitialise(classFade FadeData) |
roryhand | 64:6061ffe25985 | 443 | { |
roryhand | 64:6061ffe25985 | 444 | FadeData.DecayFactor = 1.3; |
roryhand | 64:6061ffe25985 | 445 | FadeData.FadeIteration = 1; |
roryhand | 64:6061ffe25985 | 446 | //FadeData.Denom = 11025*FadeData.DecayFactor; |
roryhand | 64:6061ffe25985 | 447 | FadeData.Denom = 11025*FadeData.DecayFactor; |
roryhand | 64:6061ffe25985 | 448 | FadeData.Natural_Exp = 2.7183; |
roryhand | 64:6061ffe25985 | 449 | FadeData.Length = 11025*FadeData.LengthSecs; |
roryhand | 64:6061ffe25985 | 450 | //FadeData.Natural_Exp = 2.7; |
roryhand | 64:6061ffe25985 | 451 | return FadeData; |
roryhand | 64:6061ffe25985 | 452 | } |
roryhand | 1:aac37edee302 | 453 | |
roryhand | 1:aac37edee302 | 454 | |
roryhand | 1:aac37edee302 | 455 | |
roryhand | 0:e89d7a0bfa3b | 456 | |
roryhand | 0:e89d7a0bfa3b | 457 | void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo) |
roryhand | 0:e89d7a0bfa3b | 458 | { |
roryhand | 1:aac37edee302 | 459 | while(slice<FileInfo.num_slices) { |
roryhand | 1:aac37edee302 | 460 | fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav); |
roryhand | 1:aac37edee302 | 461 | data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples |
roryhand | 1:aac37edee302 | 462 | for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) { |
roryhand | 1:aac37edee302 | 463 | if(flag1 == 1) { |
roryhand | 1:aac37edee302 | 464 | Buffer1[place_hold1] = data_sptr[channel]; |
roryhand | 1:aac37edee302 | 465 | place_hold1 = place_hold1 + 1; |
roryhand | 1:aac37edee302 | 466 | if(place_hold1 >= BufferLen) { |
roryhand | 1:aac37edee302 | 467 | while(1) { |
roryhand | 1:aac37edee302 | 468 | if(flag1 == 0) { |
roryhand | 0:e89d7a0bfa3b | 469 | |
roryhand | 1:aac37edee302 | 470 | break; |
roryhand | 0:e89d7a0bfa3b | 471 | } |
roryhand | 1:aac37edee302 | 472 | |
roryhand | 0:e89d7a0bfa3b | 473 | } |
roryhand | 1:aac37edee302 | 474 | } |
roryhand | 1:aac37edee302 | 475 | |
roryhand | 1:aac37edee302 | 476 | } else if(flag2 == 1) { |
roryhand | 1:aac37edee302 | 477 | Buffer2[place_hold2] = data_sptr[channel]; |
roryhand | 1:aac37edee302 | 478 | place_hold2 = place_hold2 + 1; |
roryhand | 1:aac37edee302 | 479 | if(place_hold2 >= BufferLen) { |
roryhand | 1:aac37edee302 | 480 | |
roryhand | 1:aac37edee302 | 481 | while(1) { |
roryhand | 1:aac37edee302 | 482 | if(flag2 == 0) { |
roryhand | 1:aac37edee302 | 483 | |
roryhand | 1:aac37edee302 | 484 | break; |
roryhand | 1:aac37edee302 | 485 | } |
roryhand | 0:e89d7a0bfa3b | 486 | } |
roryhand | 1:aac37edee302 | 487 | } |
roryhand | 0:e89d7a0bfa3b | 488 | } |
roryhand | 1:aac37edee302 | 489 | |
roryhand | 1:aac37edee302 | 490 | } |
roryhand | 1:aac37edee302 | 491 | slice = slice + 1; |
roryhand | 0:e89d7a0bfa3b | 492 | } |
roryhand | 0:e89d7a0bfa3b | 493 | } |
roryhand | 0:e89d7a0bfa3b | 494 | |
roryhand | 0:e89d7a0bfa3b | 495 | |
roryhand | 0:e89d7a0bfa3b | 496 | |
roryhand | 0:e89d7a0bfa3b | 497 | |
roryhand | 38:3b4c05af5f36 | 498 | //***************************************************************************// |
roryhand | 38:3b4c05af5f36 | 499 | |
roryhand | 38:3b4c05af5f36 | 500 | //**************************************************************************// |
roryhand | 38:3b4c05af5f36 | 501 | |
roryhand | 38:3b4c05af5f36 | 502 | |
roryhand | 38:3b4c05af5f36 | 503 | |
roryhand | 38:3b4c05af5f36 | 504 | |
roryhand | 38:3b4c05af5f36 | 505 | |
roryhand | 59:8e7c25a915a0 | 506 | |
roryhand | 44:a9e84d333a6a | 507 | |
roryhand | 57:0c76b15cabaf | 508 | void Play_WaveFileLoop(classSoundFile Sound1, FILE *wavfile1, classPositionIndicators Positions) |
roryhand | 45:0e8e1f2ec5d2 | 509 | { |
roryhand | 45:0e8e1f2ec5d2 | 510 | while(1) { //might have to change this to a while(1) loop? |
roryhand | 44:a9e84d333a6a | 511 | |
roryhand | 2:957d3b2afff4 | 512 | |
roryhand | 44:a9e84d333a6a | 513 | |
roryhand | 44:a9e84d333a6a | 514 | |
roryhand | 54:606a83fff291 | 515 | |
roryhand | 44:a9e84d333a6a | 516 | //Sound1======================================================================================= |
roryhand | 61:212d2db45c56 | 517 | if( slice1 == (Positions.notch8_start_pt) ) { |
roryhand | 61:212d2db45c56 | 518 | slice1 = Positions.notch7_start_pt; |
roryhand | 61:212d2db45c56 | 519 | fseek(wavfile1,Positions.notch7_start_pt,SEEK_SET); |
roryhand | 2:957d3b2afff4 | 520 | } |
roryhand | 57:0c76b15cabaf | 521 | |
roryhand | 44:a9e84d333a6a | 522 | fread(Sound1.FileInfo.slice_buf,Sound1.FileInfo.FileFormat.block_align,1,wavfile1); |
roryhand | 44:a9e84d333a6a | 523 | Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf; // 16 bit samples |
roryhand | 44:a9e84d333a6a | 524 | //============================================================================================= |
roryhand | 44:a9e84d333a6a | 525 | |
roryhand | 58:a174e7a8f5f2 | 526 | |
roryhand | 1:aac37edee302 | 527 | |
roryhand | 1:aac37edee302 | 528 | |
roryhand | 44:a9e84d333a6a | 529 | |
roryhand | 45:0e8e1f2ec5d2 | 530 | for (channel=0; channel<Sound1.FileInfo.FileFormat.num_channels; channel++) { |
roryhand | 45:0e8e1f2ec5d2 | 531 | switch (Sound1.FileInfo.FileFormat.sig_bps) { |
roryhand | 0:e89d7a0bfa3b | 532 | case 16: |
roryhand | 1:aac37edee302 | 533 | if(flag1 == 1) { |
roryhand | 45:0e8e1f2ec5d2 | 534 | Buffer1[place_hold1] = Sound1.data_sptr[channel]; |
roryhand | 1:aac37edee302 | 535 | place_hold1 = place_hold1 + 1; |
roryhand | 1:aac37edee302 | 536 | if(place_hold1 >= BufferLen) { |
roryhand | 1:aac37edee302 | 537 | while(1) { |
roryhand | 1:aac37edee302 | 538 | if(flag1 == 0) { |
roryhand | 1:aac37edee302 | 539 | break; |
roryhand | 1:aac37edee302 | 540 | }//if(flag1 == 0) |
roryhand | 1:aac37edee302 | 541 | |
roryhand | 1:aac37edee302 | 542 | |
roryhand | 1:aac37edee302 | 543 | }//while(1) |
roryhand | 1:aac37edee302 | 544 | }//if(place_hold1 > = BufferLen) |
roryhand | 0:e89d7a0bfa3b | 545 | |
roryhand | 1:aac37edee302 | 546 | } else if(flag2 == 1) { |
roryhand | 45:0e8e1f2ec5d2 | 547 | Buffer2[place_hold2] = Sound1.data_sptr[channel]; |
roryhand | 1:aac37edee302 | 548 | place_hold2 = place_hold2 + 1; |
roryhand | 1:aac37edee302 | 549 | if(place_hold2 >= BufferLen) { |
roryhand | 1:aac37edee302 | 550 | while(1) { |
roryhand | 1:aac37edee302 | 551 | |
roryhand | 1:aac37edee302 | 552 | if(flag2 == 0) { |
roryhand | 1:aac37edee302 | 553 | break; |
roryhand | 1:aac37edee302 | 554 | } |
roryhand | 1:aac37edee302 | 555 | } |
roryhand | 0:e89d7a0bfa3b | 556 | } |
roryhand | 1:aac37edee302 | 557 | |
roryhand | 1:aac37edee302 | 558 | } |
roryhand | 0:e89d7a0bfa3b | 559 | } |
roryhand | 0:e89d7a0bfa3b | 560 | } |
roryhand | 59:8e7c25a915a0 | 561 | slice1 = slice1 + 2;//increment up by the number of bytes per Audio data sample! Makes sense it is 2 bytes, as this is 16-bit data. |
roryhand | 45:0e8e1f2ec5d2 | 562 | slice2 = slice2 + 1; |
roryhand | 45:0e8e1f2ec5d2 | 563 | slice3 = slice3 + 1; |
roryhand | 0:e89d7a0bfa3b | 564 | } |
roryhand | 0:e89d7a0bfa3b | 565 | } |
roryhand | 0:e89d7a0bfa3b | 566 | |
roryhand | 0:e89d7a0bfa3b | 567 | |
roryhand | 0:e89d7a0bfa3b | 568 | |
roryhand | 0:e89d7a0bfa3b | 569 | |
roryhand | 0:e89d7a0bfa3b | 570 | |
roryhand | 0:e89d7a0bfa3b | 571 | |
roryhand | 59:8e7c25a915a0 | 572 | |
roryhand | 59:8e7c25a915a0 | 573 |