old demo that i want to try in mbed studio
Dependencies: mbed SDFileSystem_Copy_of_mbed_version I2S
Revision 81:ec3a68c93bee, committed 2019-10-01
- Comitter:
- roryhand
- Date:
- Tue Oct 01 21:07:58 2019 +0000
- Branch:
- LargeFile_Tests
- Parent:
- 80:9c70dc3fc16b
- Child:
- 82:3694ee23a4d7
- Commit message:
- WIP - trying to get new block logic working
Changed in this revision
| NotchingDemo.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/NotchingDemo.cpp Tue Oct 01 20:47:13 2019 +0000
+++ b/NotchingDemo.cpp Tue Oct 01 21:07:58 2019 +0000
@@ -283,7 +283,7 @@
notch_transitions_position_indicators[14] = N2N1_start_pt;
}
};
-
+int BlockFlag;
int TransitionFlag;
void NotchUpIsr()
{
@@ -295,15 +295,15 @@
NotchFadeIn.FadeDataInitialise();
NotchFadeOut.FadeDataInitialise();
TransitionFlag = 1;
- /*
- if(SoundFlag == 1) {
- SoundFlag = 3;
+
+ if(BlockFlag == 1) {
+ BlockFlag = 0;
} else {
- SoundFlag = 1;
+ BlockFlag = 1;
}
- */
+
//printf("We are in the NotchUpIsr() section \n\r");
//NotchFadeOut.FadeDataInitialise;
}
@@ -373,7 +373,7 @@
int BellFlag = 0;
int BellFlag2 = 0;
int FadeFlag = 0;
-int BlockFlag = 0;
+//int BlockFlag = 0;
int FileSwitchFlag = 0;
@@ -493,6 +493,8 @@
TransitionFlag = 0;
+
+ BlockFlag = 0;
FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb");
FILE* wavfile2 = fopen("/sd/mydir/SoundDecoder_second/All_14_Notch_Transitions.wav","rb");
FILE* wavfile3 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb");
@@ -508,7 +510,7 @@
fseek(wavfile2,Positions.notch_transitions_start_pts[1],SEEK_SET);
fseek(wavfile3,Positions.notch_transitions_start_pts[2],Positions.notch_transitions_start_pts[2]);
printf("about to play wav file\n\r");
- Play_WaveFileLoop(Sound1,Sound2, Sound3, wavfile1,wavfile2, Positions);
+ //Play_WaveFileLoop(Sound1,Sound2, Sound3, wavfile1,wavfile2, Positions);
printf("finished playing Wav file\n\r");
@@ -635,29 +637,12 @@
slice1 = Positions.notch_start_pts[NotchingSet.Notch];
fseek(wavfile1,Positions.notch_start_pts[NotchingSet.Notch],SEEK_SET);
}
+ if(BlockFlag == 1)
+ {
+ printf("we are inside if blockflag == 1\n\r");
if(TransitionFlag) {
- //printf("TransitionFlag == 1, so now we are going to do some other processing\n\r");
- //NOTCH 1
- //OperationsTimer.reset();
- //OperationsTimer.start();
- //fpos_t position;
- //fgetpos(wavfile1,&position);
- //printf("Positions.notch_position_indicators[NotchingSet.Notch]: %d\n\r",Positions.notch_position_indicators[NotchingSet.Notch]);
- fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch-1],Positions.notch_position_indicators[NotchingSet.Notch-1]);
- ////fsetpos(wavfile1, &position);
- //OperationsTimer.stop();
- //printf("It took %d useconds to perform fseek operation.\n\r",OperationsTimer.read_us());
- //printf("We have seeked through the file\n\r");
-
-
- //printf("Size of Sound1.FileInfo.FileFormat.block_align: %d\n\r",Sound1.FileInfo.FileFormat.block_align);
-
- /*
- OperationsTimer.reset();
- OperationsTimer.start();
- */
-
+
fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch-1],Positions.notch_position_indicators[NotchingSet.Notch-1]);
fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
data_sptr1=(short *)Sound1.FileInfo.slice_buf;
@@ -665,21 +650,6 @@
- /*
- OperationsTimer.stop();
- printf("It took %d useconds to perform fread operation.\n\r",OperationsTimer.read_us());
- */
- //printf("We have now read in 2 bytes of data (i.e. 1 sample)\n\r");
-
- //printf("We have now cast this data to a short data type\n\r");
-
-
-
-
-
- //printf("We have incremented up the Positions.notch_position_indicator");
- //increment up the position indicator!
-
//NOTCH 2
fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
@@ -714,15 +684,15 @@
NotchFadeOut.FadeOut();
- /*
+
if(Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] >= (Positions.notch_transitions_start_pts[NotchingSet.NotchTransUp+1] - NotchFadeIn.Length))
{
NotchFadeIn.FadeIn();
if(Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] >= Positions.notch_transitions_start_pts[NotchingSet.NotchTransUp+1])
{
- *Sound1.data_sptr = *data_sptr2*NotchFadeIn.FadeCoeff;
- TransitionFlag = 0;
- fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
+ *Sound1.data_sptr = *data_sptr3*NotchFadeIn.FadeCoeff;
+ //TransitionFlag = 0;
+ //fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
}
else
@@ -732,17 +702,13 @@
}
- */
+
- //else
- //{
- *Sound1.data_sptr = *data_sptr1;//*NotchFadeOut.FadeCoeff;// + *data_sptr2;
- //*Sound1.data_sptr = *data_sptr1;// + *data_sptr2;
-
-
-
+ else
+ {
+ *Sound1.data_sptr = *data_sptr1*NotchFadeOut.FadeCoeff + *data_sptr2;
//include a flag here, to hand over control. Going to get a bit complicated!!!
- //}
+ }
@@ -751,17 +717,104 @@
} else {
- /*fseek(wavfile1,Positions.notch_position_indicators[1],SEEK_SET);
- OperationsTimer.reset();
- OperationsTimer.start();
- */
- fread(Sound1.FileInfo.slice_buf,Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
- /*OperationsTimer.stop();
- printf("It took %d useconds to perform fread operation.\n\r",OperationsTimer.read_us());
- Positions.notch_position_indicators[1] = Positions.notch_position_indicators[1] + 2;//i.e. 2 bytes, per sample, for 2-byte (16-bit) data
- */
- Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf; // 16 bit samples
+
+ fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
+ fread(Sound3.FileInfo.slice_buf, Sound3.FileInfo.FileFormat.block_align,1,wavfile1);
+ data_sptr1=(short *)Sound3.FileInfo.slice_buf;
+ Positions.notch_position_indicators[NotchingSet.Notch] = Positions.notch_position_indicators[NotchingSet.Notch] + 2;
+
+ }
+ }
+ else
+
+ {
+
+ if(TransitionFlag) {
+
+
+ fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch-1],Positions.notch_position_indicators[NotchingSet.Notch-1]);
+ fread(Sound3.FileInfo.slice_buf, Sound3.FileInfo.FileFormat.block_align,1,wavfile1);
+ data_sptr3=(short *)Sound3.FileInfo.slice_buf;
+ Positions.notch_position_indicators[NotchingSet.Notch-1] = Positions.notch_position_indicators[NotchingSet.Notch-1] + 2;
+
+
+
+ //NOTCH 2
+
+ fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
+ fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
+ data_sptr1=(short *)Sound1.FileInfo.slice_buf;
+ Positions.notch_position_indicators[NotchingSet.Notch] = Positions.notch_position_indicators[NotchingSet.Notch] + 2;
+
+ //increment up the position indicator!
+
+
+ if(NotchingSet.NotchDirection)
+
+ {
+ //printf("Reached if(NotchingSet.NotchDirection)\n\r");
+
+ //N1 N2 Transition
+ fseek(wavfile2,Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp],Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp]);
+ fread(Sound2.FileInfo.slice_buf, Sound2.FileInfo.FileFormat.block_align,1,wavfile2);
+ data_sptr2=(short *)Sound2.FileInfo.slice_buf;
+ Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] = Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] + 2;
+ } else {
+ //N1 N2 Transition
+ fseek(wavfile2,Positions.notch_transitions_position_indicators[NotchingSet.NotchTransDown],Positions.notch_position_indicators[NotchingSet.NotchTransDown]);
+ fread(Sound2.FileInfo.slice_buf, Sound2.FileInfo.FileFormat.block_align,1,wavfile2);
+ data_sptr2=(short *)Sound2.FileInfo.slice_buf;
+ Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] = Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] + 2;
+
+ }
+
+
+
+
+ NotchFadeOut.FadeOut();
+
+ if(Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] >= (Positions.notch_transitions_start_pts[NotchingSet.NotchTransUp+1] - NotchFadeIn.Length))
+ {
+ NotchFadeIn.FadeIn();
+ if(Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] >= Positions.notch_transitions_start_pts[NotchingSet.NotchTransUp+1])
+ {
+ *Sound1.data_sptr = *data_sptr1*NotchFadeIn.FadeCoeff;
+ //TransitionFlag = 0;
+ //fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
+
+ }
+ else
+ {
+ *Sound1.data_sptr = *data_sptr3*NotchFadeOut.FadeCoeff + *data_sptr2 + *data_sptr1*NotchFadeIn.FadeCoeff;
+ }
+
+
+ }
+
+
+ else
+ {
+ *Sound1.data_sptr = *data_sptr3*NotchFadeOut.FadeCoeff + *data_sptr2;
+ //include a flag here, to hand over control. Going to get a bit complicated!!!
+ }
+
+
+
+
+
+
+ } else {
+
+
+ fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
+ fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
+ data_sptr1=(short *)Sound1.FileInfo.slice_buf;
+ Positions.notch_position_indicators[NotchingSet.Notch] = Positions.notch_position_indicators[NotchingSet.Notch] + 2;
+
+ }
+
+
}
//=============================================================================================
@@ -804,11 +857,4 @@
slice2 = slice2 + 1;
slice3 = slice3 + 1;
}
-}
-
-
-
-
-
-
-
+}
\ No newline at end of file