Mercurial > hg > audio-time-warp
changeset 11:68e7b61744b6
Improved switching between the played and recorded files
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Thu, 10 Nov 2011 17:31:05 +0000 |
parents | 69419f188284 |
children | 13c19fe83301 |
files | src/testApp.cpp |
diffstat | 1 files changed, 19 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testApp.cpp Wed Nov 09 18:34:25 2011 +0000 +++ b/src/testApp.cpp Thu Nov 10 17:31:05 2011 +0000 @@ -93,6 +93,8 @@ //this os load soundfiles string fullFileName = "/Users/andrew/Documents/work/programming/of_preRelease_v0061_osx_FAT/apps/my_openFrameworks/chromaReader13audioTimeWarp3/bin/data/sound/Bach_short1.wav"; + secondFileName = "/Users/andrew/Documents/work/programming/of_preRelease_v0061_osx_FAT/apps/my_openFrameworks/chromaReader13audioTimeWarp3/bin/data/sound/Bach_short2.wav"; + loadNewAudio(fullFileName); /* @@ -111,7 +113,6 @@ // secondFileName = "../../../data/sound/Bach_short2.wav"; - secondFileName = "/Users/andrew/Documents/work/programming/of_preRelease_v0061_osx_FAT/apps/my_openFrameworks/chromaReader13audioTimeWarp3/bin/data/sound/Bach_short2.wav"; loadSecondAudio(secondFileName);//i.e. load same as first file @@ -170,7 +171,7 @@ tw.forwardsAlignmentPath.clear(); //causal part int hopsize = 200; - int frameSize = 400; + int frameSize = 600; int startFrameY = 0; int startFrameX = 0; tw.anchorPoints.clear(); @@ -1463,37 +1464,45 @@ //swapping between files //printf("current playing (energy scale) frame was %i \n", currentPlayingFrame); float oldPosition = (*playingAudio).getPosition(); - printf("\n playing position is %f and conv factor %f \n", (*playingAudio).getPosition(), conversionFactor); - + printf("\n playing position is %f \n", oldPosition);//and conv factor %f \n", (*playingAudio).getPosition(), conversionFactor); + float currentPlayingFileLength; + float newFileLength; //(*playingAudio).stop(); (*playingAudio).setPaused(true); int newIndicator; if (firstAudioFilePlaying){ playingAudio = &secondAudio; newIndicator = 1; + currentPlayingFileLength = tw.firstEnergyVector.size(); + newFileLength = tw.secondEnergyVector.size(); } else{ playingAudio = &loadedAudio; newIndicator = 0; + currentPlayingFileLength = tw.secondEnergyVector.size(); + newFileLength = tw.firstEnergyVector.size(); } //printf("new indicator %i \n", newIndicator); - printf("playing pos according to energy frames is %f \n ", + printf("playing pos according to energy frames is %f; ", (currentPlayingFrame/((float)tw.backwardsAlignmentPath[1-newIndicator][0])) );//* conversionFactor)) );//CHROMA_CONVERSION_FACTOR - printf("predicts frame to be %f \n", (oldPosition*tw.backwardsAlignmentPath[1-newIndicator][0])); + printf("Current frame %f, predicts new frame to be roughly %f \n", + (oldPosition*tw.backwardsAlignmentPath[newIndicator][0]), (oldPosition*tw.backwardsAlignmentPath[1-newIndicator][0])); + printf("file lenbgths are now %i and other %i\n", tw.backwardsAlignmentPath[newIndicator][0], tw.backwardsAlignmentPath[1-newIndicator][0]); + printf("compared to energy vec lengths %i and %i\n", tw.firstEnergyVector.size(), tw.secondEnergyVector.size()); -// currentChromaFrame = oldPosition * (float) tw.backwardsAlignmentPath[1-newIndicator][0]; - currentChromaFrame = currentPlayingFrame;// / conversionFactor; + currentChromaFrame = round(oldPosition * currentPlayingFileLength); +// currentChromaFrame = currentPlayingFrame;// / conversionFactor; printf("current chroma frame %i \n", currentChromaFrame);//and using energy frames would have been %i \n", currentChromaFrame, currentPlayingFrame / conversionFactor);//CHROMA_CONVERSION_FACTOR); int matchingFrame = findMatchFromAlignment(firstAudioFilePlaying); - float relativePosition = matchingFrame / (float) tw.backwardsAlignmentPath[newIndicator][0]; + float relativePosition = matchingFrame / newFileLength;// tw.backwardsAlignmentPath[newIndicator][0]; //i.e. the position as float [0,1] 0:beginning, 1 is end (*playingAudio).setPaused(false); (*playingAudio).setPosition(relativePosition); - printf("matching frame is %i and length is %i \n", matchingFrame, tw.backwardsAlignmentPath[newIndicator][0]); + printf("matching frame is %i \n", matchingFrame, tw.backwardsAlignmentPath[newIndicator][0]); printf("new playing position is %f and back align index %i \n", (*playingAudio).getPosition(), backwardsAlignmentIndex); firstAudioFilePlaying = !firstAudioFilePlaying;