You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(43) |
May
(14) |
Jun
(17) |
Jul
(19) |
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
(19) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(13) |
Feb
(15) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mc...@us...> - 2010-11-29 23:09:00
|
Revision: 238 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=238&view=rev Author: mchinen Date: 2010-11-29 23:08:54 +0000 (Mon, 29 Nov 2010) Log Message: ----------- add stop button Modified Paths: -------------- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-11-25 03:15:12 UTC (rev 237) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-11-29 23:08:54 UTC (rev 238) @@ -13,6 +13,7 @@ bool startButton; bool genButton; string textInput; +ofxSimpleGuiButton *startButtonControl; //-------------------------------------------------------------- void testApp::setup(){ bDrawConsole = true; @@ -20,7 +21,7 @@ bDrawSquares = false; currFontSize = 10; arrayFont.loadFont("Courier New.ttf", currFontSize, true, true); -// arrayFont.setLineHeight(10.0f); + // arrayFont.setLineHeight(10.0f); ofBackground(255,255,255); speedSliderVal = speedSliderVal_old = 25; @@ -29,18 +30,18 @@ arraysize = prev_arraysize = 10; gui.addSlider("Array Size", arraysize, 2, 200); gui.addToggle("Loop", bLoop); - + string algostrings[eNumSortAlgorithms]; for(int i = 0;i<eNumSortAlgorithms;i++) algostrings[i] = gAlgoStrings[i]; - - ofxSimpleGuiComboBox& box = gui.addComboBox("Sorting Algorithm", algonum, eNumSortAlgorithms,algostrings); + + gui.addComboBox("Sorting Algorithm", algonum, eNumSortAlgorithms,algostrings); gui.addTextInput("number",textInput); - gui.addButton("Start", startButton); + startButtonControl = &gui.addButton("Start", startButton); gui.addButton("Generate New Array", genButton); - - + + gui.show(); drawGUI=true; //flags init @@ -49,27 +50,34 @@ activeEffects = eAudioEffectsAll; audioState = eAudioStateNone; - + ofSetFrameRate(60); - } //-------------------------------------------------------------- void testApp::update(){ if(startButton) { - startButton = false; - //start. - SortingMan::Instance()->StopSorting(); - SortingMan::Instance()->SortStuff(); - } + startButton = false; + //start. + if(SortingMan::Instance()->IsSorting()) { + SortingMan::Instance()->StopSorting(); + startButtonControl->setName("start"); + } else { + SortingMan::Instance()->SortStuff(); + startButtonControl->setName("stop"); + } + } else if(!SortingMan::Instance()->IsSorting()) { + if (startButtonControl->name.compare("stop") == 0) + startButtonControl->setName("start"); + } if(genButton || prev_arraysize != arraysize){ genButton = false; prev_arraysize = arraysize; SortingMan::Instance()->GenerateNewArray(arraysize); } - + SortingMan::Instance()->SetAlgorithm((SortAlgorithms)algonum); if(bLoop != SortingMan::Instance()->IsLooping()) SortingMan::Instance()->ToggleLooping(); @@ -78,8 +86,9 @@ if(speedSliderVal != speedSliderVal_old) { speedSliderVal_old = speedSliderVal; AlgorhythmicAudioIO::Instance()->ChangeSpeed(speedSliderVal/1000); - } + + } //-------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-11-25 03:15:19
|
Revision: 237 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=237&view=rev Author: mchinen Date: 2010-11-25 03:15:12 +0000 (Thu, 25 Nov 2010) Log Message: ----------- sorting: add square view (press '3' to activate) Modified Paths: -------------- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h Modified: algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-11-21 19:36:40 UTC (rev 236) +++ algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-11-25 03:15:12 UTC (rev 237) @@ -208,7 +208,7 @@ E45BE9770E8CC7DD009D7055 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; }; E45BE9790E8CC7DD009D7055 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; E45BE97A0E8CC7DD009D7055 /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = "<absolute>"; }; - E4B69B5B0A3A1756003C02F2 /* AlgorhythmicSorting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AlgorhythmicSorting.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E4B69B5B0A3A1756003C02F2 /* AlgorhythmicSortingDebug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AlgorhythmicSortingDebug.app; sourceTree = BUILT_PRODUCTS_DIR; }; E4B69E1D0A3A1BDC003C02F2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = src/main.cpp; sourceTree = SOURCE_ROOT; }; E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = testApp.cpp; path = src/testApp.cpp; sourceTree = SOURCE_ROOT; }; E4B69E1F0A3A1BDC003C02F2 /* testApp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = testApp.h; path = src/testApp.h; sourceTree = SOURCE_ROOT; }; @@ -373,7 +373,7 @@ 84BFF84911C4E64E000DB417 /* Products */ = { isa = PBXGroup; children = ( - 84BFF85011C4E64E000DB417 /* openFrameworksDebug.a */, + 84BFF85011C4E64E000DB417 /* openFrameworks.a */, ); name = Products; sourceTree = "<group>"; @@ -583,7 +583,7 @@ isa = PBXGroup; children = ( 84BFF66D11C4CD9C000DB417 /* addons */, - E4B69B5B0A3A1756003C02F2 /* AlgorhythmicSorting.app */, + E4B69B5B0A3A1756003C02F2 /* AlgorhythmicSortingDebug.app */, E4B6FCAD0C3E899E008CF71C /* openFrameworks-Info.plist */, E4B69E1C0A3A1BDC003C02F2 /* src */, E4C2422310CC54B6004149E2 /* openFrameworks */, @@ -715,7 +715,7 @@ ); name = AlgorhythmicSorting; productName = myOFApp; - productReference = E4B69B5B0A3A1756003C02F2 /* AlgorhythmicSorting.app */; + productReference = E4B69B5B0A3A1756003C02F2 /* AlgorhythmicSortingDebug.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -725,7 +725,14 @@ isa = PBXProject; buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "AlgorhythmicSorting" */; compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; hasScannedForEncodings = 0; + knownRegions = ( + English, + Japanese, + French, + German, + ); mainGroup = E4B69B4A0A3A1720003C02F2; productRefGroup = E4B69B4A0A3A1720003C02F2; projectDirPath = ""; @@ -743,10 +750,10 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 84BFF85011C4E64E000DB417 /* openFrameworksDebug.a */ = { + 84BFF85011C4E64E000DB417 /* openFrameworks.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = openFrameworksDebug.a; + path = openFrameworks.a; remoteRef = 84BFF84F11C4E64E000DB417 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -922,6 +929,7 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_MODEL_TUNING = G5; GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; @@ -959,6 +967,7 @@ GCC_OPTIMIZATION_LEVEL = 3; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_UNROLL_LOOPS = YES; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-11-21 19:36:40 UTC (rev 236) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-11-25 03:15:12 UTC (rev 237) @@ -47,8 +47,34 @@ return ret; } +void SortingMan::AppendToHistory(double *array, int n) +{ + + pthread_mutex_lock(&stringLock); + double *entry = (double*)malloc(sizeof(double) * n); + memcpy(entry, array, sizeof(double) * n); + m_history.push_back(entry); + pthread_mutex_unlock(&stringLock); +} + +double* SortingMan::PopHistory() +{ + double* ret; + //we are recylcing mutexes. + pthread_mutex_lock (&stringLock); + if(m_history.size()) { + ret = m_history[0]; + m_history.erase(m_history.begin() + 0); + } else { + ret = NULL; + } + pthread_mutex_unlock (&stringLock); + + return ret; +} + SortingMan* SortingMan::Instance() { static SortingMan* man=NULL; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h 2010-11-21 19:36:40 UTC (rev 236) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h 2010-11-25 03:15:12 UTC (rev 237) @@ -3,6 +3,7 @@ #include <pthread.h> #include <string> +#include <vector> using std::string; enum SortAlgorithms { @@ -44,6 +45,9 @@ void AppendToOutput(const char* inputString); char* PopOutput(); + void AppendToHistory(double *array, int n); + double* PopHistory(); + //runs on a different thread; void SortStuff(); void StopSorting(); @@ -68,7 +72,8 @@ SortingMan(); virtual ~SortingMan(); - char* volatile m_outputString; + char* volatile m_outputString; + std::vector<double*> m_history; // pthread_mutex_t m_outViewMutex; bool m_inited; bool m_looping; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp 2010-11-21 19:36:40 UTC (rev 236) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp 2010-11-25 03:15:12 UTC (rev 237) @@ -83,6 +83,7 @@ SortingMan::Instance()->AppendToOutput(myString); // [myString autorelease]; } + SortingMan::Instance()->AppendToHistory(array, size); SortingMan::Instance()->SetArrayStatus(arrayStatus); sprintf(myString,"\n"); Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-11-21 19:36:40 UTC (rev 236) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-11-25 03:15:12 UTC (rev 237) @@ -17,6 +17,7 @@ void testApp::setup(){ bDrawConsole = true; bDrawBars = false; + bDrawSquares = false; currFontSize = 10; arrayFont.loadFont("Courier New.ttf", currFontSize, true, true); // arrayFont.setLineHeight(10.0f); @@ -83,216 +84,8 @@ //-------------------------------------------------------------- void testApp::draw(){ - -// -//#define kY1Rect 50 -//#define kY2Rect 350 -//#define kYRingRect 200 -//#define kRectHeight 50 -//#define kRingRectWidth 900 -//#define kRingRectLeft 50 -////in -// // draw the left: -// ofSetColor(0x333333); -// ofRect(100,kY1Rect,256,kRectHeight); -// ofSetColor(0xFFFFFF); -// for (int i = 0; i < 256; i++){ -// ofLine(100+i,kY1Rect+kRectHeight/2,100+i,kY1Rect+kRectHeight/2+lIn[i]*kRectHeight/2); -// } -// -// // draw the right: -// ofSetColor(0x333333); -// ofRect(600,kY1Rect,256,kRectHeight); -// ofSetColor(0xFFFFFF); -// for (int i = 0; i < 256; i++){ -// ofLine(600+i,kY1Rect+kRectHeight/2,600+i,kY1Rect+kRectHeight/2+rIn[i]*kRectHeight/2); -// } -// -// /* ---------------------------------- RING BUFFER ----------------------------------------- */ -// -// ofSetColor(0x333333); -// ofRect(kRingRectLeft,kYRingRect,kRingRectWidth,kRectHeight*2); -// ofSetColor(0xFFFFFF); -// //samples -// float samplesPerPixel = kTatsumiRingBufferSize/(ringZoom*kRingRectWidth); -// //we don't do anything fancy like calculate rms so the display will be pretty rough -// int startRing =0; -// int ringDrawIndex; -// if(ringZoom > 1.0) -// { -// startRing = writeRingCursor - (kTatsumiRingBufferSize/ringZoom); -// } -// for (int i = 0; i < kRingRectWidth; i++){ -// ringDrawIndex = (i*samplesPerPixel) + startRing; -// while(ringDrawIndex > kTatsumiRingBufferSize) -// ringDrawIndex-=kTatsumiRingBufferSize; -// -// ofLine(kRingRectLeft+i,kYRingRect+kRectHeight/2,kRingRectLeft+i,kYRingRect+kRectHeight/2+lRing[ringDrawIndex]*kRectHeight/2); -// ofLine(kRingRectLeft+i,kYRingRect+kRectHeight*1.5,kRingRectLeft+i,kYRingRect+kRectHeight*1.5+rRing[ringDrawIndex]*kRectHeight/2); -// } -// -// //draw line for ring buffer cursor -// int lineX,lineX2; -// if(ringZoom>1.0) -// lineX = kRingRectWidth; -// else -// lineX = ((float)writeRingCursor/kTatsumiRingBufferSize)*kRingRectWidth; -// ofSetColor(0x00FF00); -// ofLine(kRingRectLeft+lineX,kYRingRect,kRingRectLeft+lineX,kYRingRect+kRectHeight*2); -// -// -// //draw the delay points. we don't need to mutex because the vectors are modified on this thread. -// ofSetColor(0x000000); -// for (int i = 0 ; i< delayPoints.size();i++) -// { -// int delayX; -// delayX = ((float)(delayPoints[i]-startRing) /(kTatsumiRingBufferSize/ringZoom))*kRingRectWidth; -// ofLine(kRingRectLeft+delayX,kYRingRect+kRectHeight*2,kRingRectLeft+delayX,kYRingRect+kRectHeight*2 + 8); -// } -// -// -// //draw the loop points. we don't need to mutex because the vectors are modified on this thread. -// -// -// for (int i = 0 ; i< loopPoints.size();i++) -// { -// ofEnableAlphaBlending(); // turn on alpha blending so we can see overlapping loops -// ofSetColor((i%3)*127,((i+1)%4)*255/3,((i+2)%5)*255/4,127); // -// lineX = ((float)loopStartPoints[i]/kTatsumiRingBufferSize)*kRingRectWidth; -// lineX2 = ((float)loopEndPoints[i]/kTatsumiRingBufferSize)*kRingRectWidth; -// -// if(lineX2>=lineX) -// { -// ofRect(kRingRectLeft+lineX,kYRingRect-((i%7)+2),lineX2-lineX,((i%7)+2)); -// } -// else -// { -// ofRect(kRingRectLeft+lineX,kYRingRect-((i%7)+2),(kRingRectWidth)-lineX,((i%7)+2)); -// ofRect(kRingRectLeft,kYRingRect-((i%7)+2),lineX2,((i%7)+2)); -// } -// ofSetColor(0,0,0,127); // -// -// //draw borders that stick out -// ofLine(kRingRectLeft+lineX,kYRingRect-10,kRingRectLeft+lineX,kYRingRect); -// ofLine(kRingRectLeft+lineX2,kYRingRect-12,kRingRectLeft+lineX2,kYRingRect); -// lineX = ((float)loopPoints[i]/kTatsumiRingBufferSize)*kRingRectWidth; -// //draw cursor -// ofLine(kRingRectLeft+lineX,kYRingRect-8,kRingRectLeft+lineX,kYRingRect); -// ofDisableAlphaBlending(); -// } -// -// ofSetColor(0x333333); -// drawCounter++; - -// char mouseString[255]; -// char effectsString[255]; -// -// sprintf(reportString, "buffers received: %i\ndraw routines called: %i\n", bufferCounter,drawCounter); -// ofDrawBitmapString(reportString,80,10); -// -////out -// // draw the left: -// ofSetColor(0x333333); -// ofRect(100,kY2Rect,256,kRectHeight); -// ofSetColor(0xFFFFFF); -// for (int i = 0; i < 256; i++){ -// ofLine(100+i,kY2Rect+kRectHeight/2,100+i,kY2Rect+kRectHeight/2+lAudio[i]*kRectHeight/2); -// } -// -// // draw the right: -// ofSetColor(0x333333); -// ofRect(600,kY2Rect,256,kRectHeight); -// ofSetColor(0xFFFFFF); -// for (int i = 0; i < 256; i++){ -// ofLine(600+i,kY2Rect+kRectHeight/2,600+i,kY2Rect+kRectHeight/2+rAudio[i]*kRectHeight/2); -// } -// -// -// //draw the input mixers -// -// -// // draw the right: -//#define kMixerTrackWidth 25 -//#define kMixerTrackHeight 80 -//#define kMixerTrackLeft 600 -//#define kMixerTrackThruTop 430 -//#define kMixerTrackRingTop 520 -//#define kMaxMixerLevel 8.0 -// -// //draw input mixers -// -// float dbmin = -60.0; -// float dbmax = amptodb(kMaxMixerLevel); -//for(int g=0;g<2;g++) -// for(int h=0;h<4;h++) -// { -// float level; -// int lineY; -// int topY; -// topY = g==0?kMixerTrackThruTop:kMixerTrackRingTop; -// -// ofSetColor(0x333333); -// ofRect(kMixerTrackLeft+h*kMixerTrackWidth,topY,kMixerTrackWidth,kMixerTrackHeight); -// -// //draw 0db/1.0 ref -// ofSetColor(0x777777); -// lineY = topY +kMixerTrackHeight -((amptodb(1.0)-dbmin)/(dbmax-dbmin))*kMixerTrackHeight; -// ofLine(kMixerTrackLeft+h*kMixerTrackWidth,lineY,kMixerTrackLeft+(h+1)*kMixerTrackWidth-1,lineY); -// -// //draw actual level -// //ptr hack. -// level = *((g==0?&input1ToLLevel:&input1ToLRing) + h); -// -// -// lineY = topY +kMixerTrackHeight - ((amptodb(level)-dbmin)/(dbmax-dbmin))*kMixerTrackHeight; -// -// ofSetColor(0x00FF00); -// for (int i = 0; i < 3; i++){ -// ofLine(kMixerTrackLeft+h*kMixerTrackWidth,lineY+i,kMixerTrackLeft+(h+1)*kMixerTrackWidth-1,lineY+i); -// } -// } -// -// -// ofSetColor(0x333333); -// -// strcpy(mouseString, ""); -// if(mouseMode&eMouseModeNoise1) -// strcat(mouseString, "noise1 "); -// if(mouseMode&eMouseModeNoise2) -// strcat(mouseString, "noise2 "); -// if(mouseMode&eMouseModePanNoise) -// strcat(mouseString, "pnoise "); -// if(mouseMode&eMouseModePan) -// strcat(mouseString, "pan "); -// if(mouseMode&eMouseModeFeedback) -// strcat(mouseString, "feedback "); -// if(mouseMode&eMouseModeDownsample) -// strcat(mouseString, "downsamp "); -// -// strcpy(effectsString, ""); -// if(activeEffects&eAudioEffectsNoise1) -// strcat(effectsString, "noise1 "); -// if(activeEffects&eAudioEffectsNoise2) -// strcat(effectsString, "noise2 "); -// if(activeEffects&eAudioEffectsPanNoise) -// strcat(effectsString, "pnoise "); -// if(activeEffects&eAudioEffectsNoiseRing) -// strcat(effectsString, "noisering "); -// if(activeEffects&eAudioEffectsDownsample) -// strcat(effectsString, "downsamp "); -// -// -// sprintf(reportString, "volume: (%f) modify with -/+ keys\nzoom: (%f) \nEffects: %s\nMouseMode: %s\nKeyMode: %s", -// volume, -// ringZoom, -// effectsString, -// mouseString, -// keyMode&eKeyModeZoom ? "zoom" : keyMode& eKeyModeMouse?"mouse":keyMode&eKeyModeEffects?"effects":"normal" -// ); -//// if (!bNoise) sprintf(reportString, "%s (%fhz)", reportString, targetFrequency); -// -// ofDrawBitmapString(reportString,80,600); drawBars(); + drawSquares(); drawConsole(); @@ -341,84 +134,130 @@ (float)ofGetWidth()/len, fabs(y1-y2)); } } -void testApp::drawConsole() + +void testApp::drawSquares() { + static vector<double*> history; + static int lastlen = -1; + int len = SortingMan::Instance()->GetArraySize(); - static int bufsize = 0; - char* poppedString; - unsigned int popsize; - poppedString = SortingMan::Instance()->PopOutput(); - //only draw if we have something. don't use strlen cause it can be slow. - if(poppedString[0]!=0) { - popsize = strlen(poppedString);//take off the null terminator, since this won't be copied -// free(lastDrawString); - if(popsize > kArraysStringMaxSize) { - strcpy(lastDrawString, poppedString+(popsize-kArraysStringMaxSize)); - bufsize = kArraysStringMaxSize; - } - else if(bufsize + popsize>kArraysStringMaxSize) { - memmove(lastDrawString, lastDrawString+(bufsize-popsize), popsize); - strcpy(lastDrawString+(kArraysStringMaxSize-popsize),poppedString); - bufsize = kArraysStringMaxSize; - } - else{ - strcat(lastDrawString,poppedString); - bufsize+=popsize; - } - - //compute where we should start -#define kConsoleX 10 -#define kConsoleY 10 + double* array; + + if (lastlen != len) { + for(int i = 0; i < history.size(); i++) + free(history[i]); + history.clear(); + } - int desiredFontSize = 10; - if(prev_arraysize > 30) - { - desiredFontSize = mymax(10.0 - (prev_arraysize/30.0), 4.0); + while(array = SortingMan::Instance()->PopHistory()) { + history.push_back(array); } - if(currFontSize!=desiredFontSize) { - arrayFont.loadFont("Courier New.ttf",desiredFontSize,true, true); - currFontSize = desiredFontSize; - } - int width = ofGetWidth(); - int screenHeight = ofGetHeight() - kConsoleY; - int lineHeight = arrayFont.getLineHeight(); - int n = bufsize; - int lines=0; - while(--n > -1) { - - if(lastDrawString[n]=='\n') { - lines++; - } - if(lines*lineHeight>screenHeight) - { - n++;//restore n to point after the endline. - break; - } - - } - - //truncate the string. - if(n>0) { - memmove(lastDrawString, lastDrawString+n, bufsize-n); + int viewWidth = ofGetWidth() - 10; + int viewHeight = ofGetHeight() - 10; + int squareSize = viewWidth / len; + int numRows = viewHeight / squareSize; - bufsize -= n; - lastDrawString[bufsize]=0;//put a new null term. - } - - + while (history.size() > numRows) { + free(history[0]); + history.erase(history.begin() + 0); } + + int startRow = numRows - history.size(); + if(bDrawSquares) { + for(int i = startRow; i < numRows; i++) { + for(int j = 0; j < len; j++) { + int val; + int color; + val = history[i - startRow][j]; + color = 0xFF * ((float) (val+100)/200.0);//brightness + //copy to other bytes + color |= color << 8 | color << 16; + ofSetColor(color); + ofRect( 5 + j * squareSize, 5 + i * squareSize, + squareSize, squareSize); + } + } + } + lastlen = len; +} - free(poppedString); - - - - - if(lastDrawString && bDrawConsole){ - ofSetColor(0xFF0000); -// ofDrawBitmapString(lastDrawString,kConsoleX,kConsoleY); - arrayFont.drawString(lastDrawString,kConsoleX,kConsoleY); - } +void testApp::drawConsole() +{ + static int bufsize = 0; + char* poppedString; + unsigned int popsize; + static int lines=0; + + poppedString = SortingMan::Instance()->PopOutput(); + //only draw if we have something. don't use strlen cause it can be slow. + if(poppedString[0]!=0) { + popsize = strlen(poppedString);//take off the null terminator, since this won't be copied + // free(lastDrawString); + if(popsize > kArraysStringMaxSize) { + strcpy(lastDrawString, poppedString+(popsize-kArraysStringMaxSize)); + bufsize = kArraysStringMaxSize; + } + else if(bufsize + popsize>kArraysStringMaxSize) { + memmove(lastDrawString, lastDrawString+(bufsize-popsize), popsize); + strcpy(lastDrawString+(kArraysStringMaxSize-popsize),poppedString); + bufsize = kArraysStringMaxSize; + } + else{ + strcat(lastDrawString,poppedString); + bufsize+=popsize; + } + + //compute where we should start +#define kConsoleX 10 +#define kConsoleY 10 + + int desiredFontSize = 10; + if(prev_arraysize > 30) + { + desiredFontSize = mymax(10.0 - (prev_arraysize/30.0), 4.0); + } + if(currFontSize!=desiredFontSize) { + arrayFont.loadFont("Courier New.ttf",desiredFontSize,true, true); + currFontSize = desiredFontSize; + } + + int width = ofGetWidth(); + int screenHeight = ofGetHeight() - kConsoleY; + int lineHeight = arrayFont.getLineHeight(); + int n = bufsize; + lines = 0; + while(--n > -1) { + + if(lastDrawString[n]=='\n') { + lines++; + } + if(lines*lineHeight>screenHeight) + { + n++;//restore n to point after the endline. + break; + } + + } + + //truncate the string. + if(n>0) { + memmove(lastDrawString, lastDrawString+n, bufsize-n); + + bufsize -= n; + lastDrawString[bufsize]=0;//put a new null term. + } + + + } + + free(poppedString); + + if(lastDrawString && bDrawConsole){ + ofSetColor(0xFF0000); + // ofDrawBitmapString(lastDrawString,kConsoleX,kConsoleY); + arrayFont.drawString(lastDrawString,kConsoleX,kConsoleY); + } } //-------------------------------------------------------------- @@ -518,6 +357,9 @@ volume = MIN(volume, 1); } else if(key == 'c') { drawGUI=!drawGUI; + }else if(key == '3') + { + bDrawSquares = !bDrawSquares; }else if(key == '2') { bDrawBars = !bDrawBars; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h 2010-11-21 19:36:40 UTC (rev 236) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h 2010-11-25 03:15:12 UTC (rev 237) @@ -71,6 +71,7 @@ protected: void drawBars(); void drawConsole(); + void drawSquares(); float pan; @@ -140,6 +141,7 @@ bool drawGUI; bool bDrawConsole; bool bDrawBars; + bool bDrawSquares; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-11-21 19:36:47
|
Revision: 236 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=236&view=rev Author: mchinen Date: 2010-11-21 19:36:40 +0000 (Sun, 21 Nov 2010) Log Message: ----------- stacktrace fix for 10.6 i386 Modified Paths: -------------- FuckingFucker/FuckingAudioIO.cpp FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj FuckingFucker/FuckingFuckerMan.cpp FuckingFucker/FuckingFuckerMan.h FuckingFucker/FuckingFuckerView.mm FuckingFucker/boincbacktrace/QBacktrace.c FuckingFucker/boincbacktrace/QMachOImage.c FuckingFucker/boincbacktrace/QMachOImageList.c FuckingFucker/boincbacktrace/QTaskMemory.c Modified: FuckingFucker/FuckingAudioIO.cpp =================================================================== --- FuckingFucker/FuckingAudioIO.cpp 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/FuckingAudioIO.cpp 2010-11-21 19:36:40 UTC (rev 236) @@ -181,6 +181,8 @@ else if (f < -1.0) ((float*)outputBuffer)[i] = f/std::numeric_limits<float>::max(); } + + return 0; } Modified: FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj =================================================================== --- FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj 2010-11-21 19:36:40 UTC (rev 236) @@ -405,7 +405,14 @@ isa = PBXProject; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FuckingFucker" */; compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); mainGroup = 29B97314FDCFA39411CA2CEA /* FuckingFucker */; projectDirPath = ""; projectRoot = ""; @@ -658,9 +665,11 @@ buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)"; ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64"; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; LINKER_DISPLAYS_MANGLED_NAMES = NO; + MACOSX_DEPLOYMENT_TARGET = 10.6; PREBINDING = NO; PRODUCT_NAME = lstn; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; Modified: FuckingFucker/FuckingFuckerMan.cpp =================================================================== --- FuckingFucker/FuckingFuckerMan.cpp 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/FuckingFuckerMan.cpp 2010-11-21 19:36:40 UTC (rev 236) @@ -40,6 +40,7 @@ #define FUCKINGRIP rip #define FUCKINGR0 r0 #define FUCKINGEBX ebx +#define FUCKINGEDX edx #define FUCKINGESP esp #else #define FUCKINGSRR0 __srr0 @@ -47,6 +48,7 @@ #define FUCKINGRIP __rip #define FUCKINGR0 __r0 #define FUCKINGEBX __ebx +#define FUCKINGEDX __edx #define FUCKINGESP __esp #endif @@ -56,7 +58,7 @@ struct attach_data{ int targetPID; int token; - + int read_ok; void* thread_state;//can be ppc_thread_state_t or i386_thread_state_t void* float_state; @@ -316,7 +318,7 @@ FuckingAudioIO::Instance()->Init(); m_attachToken=0;//counter. - + m_readToken =0; printf("init"); //for 10.4.[6+) intel and 10.5 ppc and above we need some probably smart permission in order to get //calls like tassk_for_pid to work since they can be used for hacking. @@ -360,7 +362,7 @@ data->targetPID=pid; data->token = m_attachToken; - + data->read_ok = m_readToken++==0; if(machineEndianness()==BFD_ENDIAN_LITTLE) { //intel we have to check the task to see what we are attaching to. @@ -375,8 +377,9 @@ err = task_for_pid(mach_task_self(), pid, &task); //TODO:are we leaking this? //first attempt 32 bit. if that fails, do 64 - - err = QMOImageCreateFromTaskDyld(task, CPU_TYPE_X86, &dyld); + + //this below will fail if not run with sudo + err = QMOImageCreateFromTaskDyld(task, CPU_TYPE_X86, &dyld); if(!dyld) err = QMOImageCreateFromTaskDyld(task, CPU_TYPE_X86_64, &dyld); @@ -716,11 +719,11 @@ if(print_insn (threadState.FUCKINGEIP, info)>0) { - + //ignore ret and jae opcodes because mutex/spinlocks hog these. if(info->opcodebyte == 0xC3 || info->opcodebyte == 0x73) return -1; - + //get the actual instruction bytecode unsigned long long opcode = 0; struct dis_private* dis_priv = &info->private_data; @@ -730,8 +733,8 @@ opcode+=dis_priv->the_buffer[i]; opcode= opcode << 8; } - + opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); if(printtimer<0) @@ -739,7 +742,7 @@ printtimer=kPrintTimerFireMicros; - if(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr) + if(attach.read_ok && FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr) { #define kFFScanStart 0x00180000 //right now this only works with one task @@ -755,9 +758,9 @@ //find any pointer on heap. for now guess that ebp has something don't take values below kFFScan start and above0xc0000000 - if(threadState.__edx > kFFScanStart && threadState.__edx < 0xc0000000) { - printf("taking edx %x\n",threadState.__edx); - scanAdd = threadState.__edx; + if(threadState.FUCKINGEDX > kFFScanStart && threadState.FUCKINGEDX < 0xc0000000) { + printf("taking edx %x\n",threadState.FUCKINGEDX); + scanAdd = threadState.FUCKINGEDX; } else{ printf("continuing last addr %x\n",analysis->lastReadAddr); scanAdd = analysis->lastReadAddr; @@ -821,53 +824,51 @@ } } FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat:@"pc: 0x%X opcode:%qX byte:%.2X inst:(%s)\n",threadState.FUCKINGEIP,opcode,(int)info->opcodebyte, info->desc]); - -// printf("attempt bt 32\n"); -// //start backtrace - doesnt work for intel mac core2duo -// QBTFrame * frames; -// size_t frameToAllocate; -// size_t frameCount; -// frameToAllocate = 10; -// -// frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); -// -// int btres = QBacktraceMachThreadState( -// port, -// /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; -// &threadState, -// sizeof(i386_thread_state_t), -// CPU_TYPE_X86,// QMOGetLocalCPUType(), -// NULL,// &testSymbols,//symRef, -// 0, -// 0, -// frames, -// frameToAllocate, -// &frameCount -// ); -// char* space; -// space = (char*) malloc(frameToAllocate+1); -// //fill it with holes -// memset(space,' ',frameToAllocate); -// //terminate it -// space[frameToAllocate]=0; -// -// if(btres==0) -// { -// printf("btres ok\n",btres); -// for(int i=0;i<mymin(frameCount,frameToAllocate);i++) -// { -// //adds indentation by using pointer arithmathic and the spaces string -// FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: -// @"%spc:%qX fp:%qX %s\n", -// space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); -// -// } -// }else -// printf("btres err %d\n",btres); -// free(space); -// QBacktraceDisposeSymbols(frames,frameToAllocate); -// free(frames); -// + + //start backtrace - doesnt work for intel mac core2duo + QBTFrame * frames; + size_t frameToAllocate; + size_t frameCount; + frameToAllocate = 10; + + frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); + + int btres = QBacktraceMachThreadState( + port, + /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; + &threadState, + sizeof(i386_thread_state_t), + CPU_TYPE_X86,// QMOGetLocalCPUType(), + NULL,// &testSymbols,//symRef, + 0, + 0, + frames, + frameToAllocate, + &frameCount + ); + char* space; + space = (char*) malloc(frameToAllocate+1); + //fill it with holes + memset(space,' ',frameToAllocate); + //terminate it + space[frameToAllocate]=0; + + if(btres==0) + { + for(int i=0;i<mymin(frameCount,frameToAllocate);i++) + { + //adds indentation by using pointer arithmathic and the spaces string + FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: + @"%spc:%qX fp:%qX %s\n", + space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); + + } + }else + free(space); + + QBacktraceDisposeSymbols(frames,frameToAllocate); + free(frames); + //end backtrace } @@ -1183,8 +1184,8 @@ } } - if( (err == -1 && (FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr)) || - (!FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr && FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->keep_reading)){ + if(attach->read_ok && FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->keep_reading && ((err == -1 && (FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr)) || + (!FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr))){ // //we got a boring state not worth writing home about. // //so just allocate a buffer. opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); Modified: FuckingFucker/FuckingFuckerMan.h =================================================================== --- FuckingFucker/FuckingFuckerMan.h 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/FuckingFuckerMan.h 2010-11-21 19:36:40 UTC (rev 236) @@ -14,8 +14,8 @@ #define kFFManAudioBufferSize 50000 //#define kMemoryBufferSize 4096 -#define kMemoryBufferSize (256*13) -//#define kMemoryBufferSize 32768 +//#define kMemoryBufferSize (256*13) +#define kMemoryBufferSize 32768 #include <pthread.h> #import <Foundation/NSString.h> @@ -67,7 +67,7 @@ float GetBufferValue(int index){return m_audioBuffer[index];} float* GetBuffer(){return m_audioBuffer;} - void DetachAll(){m_attachToken++;} + void DetachAll(){m_attachToken++; m_readToken=0;} int GetCurrentAttachToken(){return m_attachToken;} opcode_analysis* GetOpcodeAnalysis(){return &m_opAnalysis;} @@ -96,6 +96,7 @@ float* m_audioBuffer; float m_speedControl; int m_attachToken; + int m_readToken; bool m_oscOn; }; Modified: FuckingFucker/FuckingFuckerView.mm =================================================================== --- FuckingFucker/FuckingFuckerView.mm 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/FuckingFuckerView.mm 2010-11-21 19:36:40 UTC (rev 236) @@ -33,7 +33,7 @@ - (void)drawRect:(NSRect)rect { - printf("draw\n"); +// printf("draw\n"); if(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr || FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->keep_reading) [readAddrTextField setStringValue:[NSString stringWithFormat:@"0x%08x",FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastReadAddr]]; Modified: FuckingFucker/boincbacktrace/QBacktrace.c =================================================================== --- FuckingFucker/boincbacktrace/QBacktrace.c 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/boincbacktrace/QBacktrace.c 2010-11-21 19:36:40 UTC (rev 236) @@ -2356,7 +2356,12 @@ // Post condition assert( (err == 0) || ! FrameArrayNeedsDispose(frameArray, frameArrayCount) ); - assert( (err == 0) == (*frameCountPtr != 0) ); + if(!(err == 0) == (*frameCountPtr != 0)) + printf("err %d, frameCount %d\n", err, *frameCountPtr); + //mchinen: add || *frameCountPtr == 0 because sometimes we get no error and no frames + //this may be due to the mach version mismatch in QMachOImageList.c's ImageListForTaskNew + //anyway in this case don't abort, just continue. + assert( ((err == 0) == (*frameCountPtr != 0)) || *frameCountPtr == 0 ); return err; } Modified: FuckingFucker/boincbacktrace/QMachOImage.c =================================================================== --- FuckingFucker/boincbacktrace/QMachOImage.c 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/boincbacktrace/QMachOImage.c 2010-11-21 19:36:40 UTC (rev 236) @@ -960,12 +960,13 @@ // we're dealing with an image that's been mapped into memory // by dyld), we operate on virtual addresses. OTOH, if the image // is coming from a file, we operate in file-relative addresses. - -printf("QMOImageMapSegmentByIndex vmaddr %llx, vmsize %llx, fileoffset %llx filesize %llx segname %s prepared(dyld) %s\n", - qmoImage->segments[segIndex].seg.vmaddr, /* memory address of this segment */ - qmoImage->segments[segIndex].seg.vmsize, /* memory size of this segment */ - qmoImage->segments[segIndex].seg.fileoff, /* file offset of this segment */ - qmoImage->segments[segIndex].seg.filesize, qmoImage->segments[segIndex].seg.segname, qmoImage->prepared?"y":"n"); /* amount to map from the file */ + +//mchinen: debug +//printf("QMOImageMapSegmentByIndex vmaddr %llx, vmsize %llx, fileoffset %llx filesize %llx segname %s prepared(dyld) %s\n", +// qmoImage->segments[segIndex].seg.vmaddr, /* memory address of this segment */ +// qmoImage->segments[segIndex].seg.vmsize, /* memory size of this segment */ +// qmoImage->segments[segIndex].seg.fileoff, /* file offset of this segment */ +// qmoImage->segments[segIndex].seg.filesize, qmoImage->segments[segIndex].seg.segname, qmoImage->prepared?"y":"n"); /* amount to map from the file */ if (qmoImage->prepared) { offset = qmoImage->segments[segIndex].seg.vmaddr + qmoImage->slide; @@ -1644,7 +1645,6 @@ // First try to remap the memory into our address space. err = QTMRemap(task, offset, length, &base); - printf("QMOImageTaskMapRange offset %llx len %llx err%d\n",offset, length,err); if (err == EFAULT) { // If the mapping fails, just read the memory. This happens if the address @@ -2005,6 +2005,8 @@ int err; bool result; struct mach_header machHeader; + + machHeader.magic = 8812; assert(task != MACH_PORT_NULL); Modified: FuckingFucker/boincbacktrace/QMachOImageList.c =================================================================== --- FuckingFucker/boincbacktrace/QMachOImageList.c 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/boincbacktrace/QMachOImageList.c 2010-11-21 19:36:40 UTC (rev 236) @@ -197,10 +197,15 @@ // only the last one varies by pointer size, so this all works; but it's // hardly nice. - if ( (err == 0) && (QMOImageToLocalUInt32(dyldImage, allImageInfo.version) != 1) ) { - err = ESHLIBVERS; - } else - printf("ImageListForTaskNew QTMRead err:%d image ver %d \n",err, allImageInfo.version); +//mchinen:version appears to have changed from 1 to 7. +//removing this check doesn't seem to break anything +// 1 was on 10.4 ppc/i386, ? on 10.5 i386, 7 on 10.6 i386 +// if ( (err == 0) && (QMOImageToLocalUInt32(dyldImage, allImageInfo.version) != 1) ) { +// err = ESHLIBVERS; +// printf("ImageListForTaskNew QTMRead err:%d image ver %d \n",err, +// QMOImageToLocalUInt32(dyldImage, allImageInfo.version)); +// } + if (err == 0) { infoCount = QMOImageToLocalUInt32(dyldImage, allImageInfo.infoArrayCount); @@ -256,7 +261,6 @@ }else printf("ImageListForTaskNew QTMRead err:%d \n",err); - printf("ImageListForTaskNew got filepath %s, slide %llx\n",filePath, QMOImageGetSlide(dyldImage)); if (err != 0) { printf("ImageListForTaskNew QMOImageCreateFromTask err:%d \n",err); // misses++; @@ -272,8 +276,6 @@ // Clean up. QTMFree(infoArrayLocal, infoArraySize); - - printf("ImageListForTaskNew leaving\n"); return err; } Modified: FuckingFucker/boincbacktrace/QTaskMemory.c =================================================================== --- FuckingFucker/boincbacktrace/QTaskMemory.c 2010-07-29 00:56:58 UTC (rev 235) +++ FuckingFucker/boincbacktrace/QTaskMemory.c 2010-11-21 19:36:40 UTC (rev 236) @@ -358,8 +358,6 @@ #if TARGET_CPU_X86 || TARGET_CPU_X86_64 mach_vm_size_t bytesRead; - - printf("aQTMRead localaddr %p size %u addr %llx \n",addrLocal,(unsigned int)size, addrWithinTask); // kr = mach_vm_read(task, addrWithinTask, (mach_vm_size_t) size, &addrLocal, &bytesRead); kr = mach_vm_read_overwrite(task, addrWithinTask, (mach_vm_size_t) size, (mach_vm_address_t) (uintptr_t) addrLocal, &bytesRead); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-29 00:57:05
|
Revision: 235 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=235&view=rev Author: mchinen Date: 2010-07-29 00:56:58 +0000 (Thu, 29 Jul 2010) Log Message: ----------- Make reading memory better by using edx register; also add options for user input Modified Paths: -------------- FuckingFucker/English.lproj/MainMenu.nib/classes.nib FuckingFucker/English.lproj/MainMenu.nib/keyedobjects.nib FuckingFucker/FuckingFuckerMan.cpp FuckingFucker/FuckingFuckerMan.h FuckingFucker/FuckingFuckerView.h FuckingFucker/FuckingFuckerView.mm Modified: FuckingFucker/English.lproj/MainMenu.nib/classes.nib =================================================================== --- FuckingFucker/English.lproj/MainMenu.nib/classes.nib 2010-07-28 18:11:44 UTC (rev 234) +++ FuckingFucker/English.lproj/MainMenu.nib/classes.nib 2010-07-29 00:56:58 UTC (rev 235) @@ -11,6 +11,12 @@ <string>id</string> <key>catchProcess</key> <string>id</string> + <key>changeKeepReading</key> + <string>id</string> + <key>changeLoadAddr</key> + <string>id</string> + <key>changeReadAddr</key> + <string>id</string> <key>changeSpeedControll</key> <string>id</string> <key>detachAll</key> @@ -36,6 +42,8 @@ <string>NSTextView</string> <key>pidInputTextField</key> <string>NSTextField</string> + <key>readAddrTextField</key> + <string>NSTextField</string> </dict> <key>SUPERCLASS</key> <string>NSOpenGLView</string> Modified: FuckingFucker/English.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: FuckingFucker/FuckingFuckerMan.cpp =================================================================== --- FuckingFucker/FuckingFuckerMan.cpp 2010-07-28 18:11:44 UTC (rev 234) +++ FuckingFucker/FuckingFuckerMan.cpp 2010-07-29 00:56:58 UTC (rev 235) @@ -39,11 +39,15 @@ #define FUCKINGEIP eip #define FUCKINGRIP rip #define FUCKINGR0 r0 +#define FUCKINGEBX ebx +#define FUCKINGESP esp #else #define FUCKINGSRR0 __srr0 #define FUCKINGEIP __eip #define FUCKINGRIP __rip #define FUCKINGR0 __r0 +#define FUCKINGEBX __ebx +#define FUCKINGESP __esp #endif void *attachProcessHelper(void* arg); @@ -301,6 +305,9 @@ m_opAnalysis.bufstart=0; m_opAnalysis.buflen=kFFManAudioBufferSize; m_opAnalysis.mode=0; + + m_opAnalysis.keep_reading = 1; + m_opAnalysis.load_addr = 1; m_opAnalysis.curr_buf = 0; m_opAnalysis.lastReadAddr = 0xFFFFFFFF; m_opAnalysis.membuf1_size = m_opAnalysis.membuf2_size = m_opAnalysis.membuf2_used = m_opAnalysis.membuf1_used = 0; @@ -535,7 +542,7 @@ //thread_set_exception_ports() - enable single stepping // we can get single step by bit ORing the 0x400UL bit to the srr0 (PC) register. for ppc i guess -#define kOpDelayMicros 5000 +#define kOpDelayMicros 1000 #define kPrintTimerFireMicros 100000 //#define kPrintTimerFireMicros 1000000 //returns -1 if no error @@ -710,8 +717,8 @@ if(print_insn (threadState.FUCKINGEIP, info)>0) { - //ignore ret opcodes - if(info->opcodebyte == 0xC3) + //ignore ret and jae opcodes because mutex/spinlocks hog these. + if(info->opcodebyte == 0xC3 || info->opcodebyte == 0x73) return -1; //get the actual instruction bytecode @@ -731,57 +738,88 @@ { printtimer=kPrintTimerFireMicros; + + if(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr) + { #define kFFScanStart 0x00180000 - //right now this only works with one task - unsigned int scanAdd; - int tries =0; - int kr; - vm_size_t bytesRead; - - if(analysis->lastReadAddr == 0xFFFFFFFF) - { - analysis->lastReadAddr = kFFScanStart; - } - //find any pointer on heap. - if(analysis->membuf1_size <= analysis->membuf1_used) { - //try the next address. - kr = 1; + //right now this only works with one task + unsigned int scanAdd; + int tries =0; + int kr; + vm_size_t bytesRead; - scanAdd = analysis->lastReadAddr; - while(kr!=0 && tries++ < 10) { - tries = 0; - kr = vm_read_overwrite(port, (vm_address_t) scanAdd, (vm_size_t) kMemoryBufferSize * sizeof(*analysis->membuf1), (vm_address_t) analysis->membuf1, &bytesRead); - if(kr!=0) { - printf("scan fail %x",scanAdd); - scanAdd = coinflip()?kFFScanStart:randint(0x80000000); - } + if(analysis->lastReadAddr == 0xFFFFFFFF) + { + analysis->lastReadAddr = kFFScanStart; } - if(kr==0){ -// printf("scan ok %i",bytesRead); - analysis->membuf1_size = bytesRead/sizeof(*analysis->membuf1); - analysis->membuf1_used = 0; - analysis->lastReadAddr = scanAdd + bytesRead; + + //find any pointer on heap. for now guess that ebp has something don't take values below kFFScan start and above0xc0000000 + if(threadState.__edx > kFFScanStart && threadState.__edx < 0xc0000000) { + printf("taking edx %x\n",threadState.__edx); + scanAdd = threadState.__edx; + } else{ + printf("continuing last addr %x\n",analysis->lastReadAddr); + scanAdd = analysis->lastReadAddr; + } - } else if(analysis->membuf2_size <= analysis->membuf2_used) { - scanAdd = analysis->lastReadAddr; - kr = 1; - while(kr!=0 && tries++ < 10) { + // scanAdd = kFFScanStart; + static vm_address_t lastAlloc = 0xFFFFFFFF; + static vm_size_t lastSize = 0; + if(1 || analysis->membuf1_size <= analysis->membuf1_used) { + + //try the next address. + kr = 1; tries = 0; - kr = vm_read_overwrite(port, (vm_address_t) scanAdd, (vm_size_t) kMemoryBufferSize, (vm_address_t) analysis->membuf2, &bytesRead); - if(kr!=0) { - printf("scan fail %x",scanAdd); - scanAdd = coinflip()?kFFScanStart:randint(0x80000000); + + while(kr!=0 && tries++ < 10) { + // if(lastAlloc != 0xFFFFFFFF) + // vm_deallocate(port, lastAlloc, lastSize); + // kr = vm_allocate(port, &lastAlloc, kMemoryBufferSize * sizeof(*analysis->membuf1), TRUE); + // if(kr == 0) + // kr = vm_read_overwrite(port, (vm_address_t) lastAlloc, (vm_size_t) kMemoryBufferSize * sizeof(*analysis->membuf1), (vm_address_t) analysis->membuf1, &bytesRead); + // + + kr = vm_read_overwrite(port, (vm_address_t) scanAdd, (vm_size_t) kMemoryBufferSize * sizeof(*analysis->membuf1), (vm_address_t) analysis->membuf1, &bytesRead); + if(kr!=0) { + printf("scan fail %x",scanAdd); + scanAdd = coinflip()?kFFScanStart:randint(0x80000000); + } } + + if(kr==0){ + // printf("scan ok %i",bytesRead); + analysis->membuf1_size = bytesRead/sizeof(*analysis->membuf1); + analysis->membuf1_used = 0; + analysis->lastReadAddr = scanAdd + bytesRead; + analysis->curr_buf = 0; + } + } else if(analysis->membuf2_size <= analysis->membuf2_used) { + + kr = 1; + tries = 0; + while(kr!=0 && tries++ < 10) { + // if(lastAlloc != 0xFFFFFFFF) + // vm_deallocate(port, lastAlloc, lastSize); + // kr = vm_allocate(port, &lastAlloc, kMemoryBufferSize * sizeof(*analysis->membuf1), TRUE); + // if(kr == 0) + // kr = vm_read_overwrite(port, (vm_address_t) lastAlloc, (vm_size_t) kMemoryBufferSize * sizeof(*analysis->membuf1), (vm_address_t) analysis->membuf1, &bytesRead); + // + + kr = vm_read_overwrite(port, (vm_address_t) scanAdd, (vm_size_t) kMemoryBufferSize, (vm_address_t) analysis->membuf2, &bytesRead); + if(kr!=0) { + printf("scan fail %x",scanAdd); + scanAdd = coinflip()?kFFScanStart:randint(0x80000000); + } + } + + if(kr==0){ + analysis->membuf2_size = bytesRead/sizeof(*analysis->membuf2); + analysis->membuf2_used = 0; + analysis->lastReadAddr = scanAdd + bytesRead; + } } - - if(kr==0){ - analysis->membuf2_size = bytesRead/sizeof(*analysis->membuf2); - analysis->membuf2_used = 0; - analysis->lastReadAddr = scanAdd + bytesRead; - } } - FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat:@"pc: 0x%X opcode:%qX byte:%.2X inst:(%s)\n",threadState.FUCKINGEIP,opcode,(int)info->opcodebyte, info->desc]); // printf("attempt bt 32\n"); @@ -878,7 +916,7 @@ return -2; } - return -1; + return 0; } @@ -1125,7 +1163,7 @@ (*attach->pf_get_thread_state)(thread_list[i], attach->thread_state, &sc ); (*attach->pf_get_float_state)(thread_list[i], attach->float_state, &sc ); err = (*attach->pf_analyze_state)(port, attach->thread_state, attach->float_state, attach, printtimer); - if( err!=-1) + if(err != 0 && err!=-1) { if(err==-2) { @@ -1143,6 +1181,37 @@ delete attach; return 0; } + } + + if( (err == -1 && (FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr)) || + (!FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr && FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->keep_reading)){ +// //we got a boring state not worth writing home about. +// //so just allocate a buffer. + opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); + int kr; + vm_size_t bytesRead; + + + //continue scanning till we hit a wall. + if(analysis->membuf1_size <= analysis->membuf1_used) { + kr = vm_read_overwrite(port, (vm_address_t) analysis->lastReadAddr, (vm_size_t) kMemoryBufferSize * sizeof(*analysis->membuf1), (vm_address_t) analysis->membuf1, &bytesRead); + + if(kr==0){ + analysis->membuf1_size = bytesRead/sizeof(*analysis->membuf1); + analysis->membuf1_used = 0; + analysis->lastReadAddr = analysis->lastReadAddr + bytesRead; + } + } else if(analysis->membuf2_size <= analysis->membuf2_used) { + kr = vm_read_overwrite(port, (vm_address_t) analysis->lastReadAddr, (vm_size_t) kMemoryBufferSize, (vm_address_t) analysis->membuf2, &bytesRead); + + if(kr==0){ + analysis->membuf2_size = bytesRead/sizeof(*analysis->membuf2); + analysis->membuf2_used = 0; + analysis->lastReadAddr = analysis->lastReadAddr + bytesRead; + } + } + + } //deallocate memory from thread_get_state - this crashes us here and seems to be unecessary //err = mach_port_deallocate(mach_task_self(), thread_list[i]); @@ -1153,7 +1222,7 @@ //let the application resume. task_resume(port); - + //deallocate the memory from task_threads err = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_array_t)); assert(err == KERN_SUCCESS); @@ -1165,6 +1234,23 @@ //save this data to the output queue string (lock/release) usleep(kOpDelayMicros*speedControl); } + + //if it was oversuspended, release the app + //let the application resume. + if(attach->token < FuckingFuckerMan::Instance()->GetCurrentAttachToken()){ + task_basic_info info; + mach_msg_type_number_t dummy; + while(1) { + dummy = sizeof(task_basic_info); + task_info(port, TASK_BASIC_INFO, (task_info_t) &info, &dummy); + if (info.suspend_count > 0) + task_resume(port); + else + break; + } + + } + //apply suspend for a certain amount of time if we have speed controll on. // mach_port_deallocate(my_task, me); (*attach->pf_cleanup_attach_data)(attach); Modified: FuckingFucker/FuckingFuckerMan.h =================================================================== --- FuckingFucker/FuckingFuckerMan.h 2010-07-28 18:11:44 UTC (rev 234) +++ FuckingFucker/FuckingFuckerMan.h 2010-07-29 00:56:58 UTC (rev 235) @@ -13,7 +13,9 @@ #define MAX_NUM_ATTACHED_THREADS 5 #define kFFManAudioBufferSize 50000 -#define kMemoryBufferSize 32768 +//#define kMemoryBufferSize 4096 +#define kMemoryBufferSize (256*13) +//#define kMemoryBufferSize 32768 #include <pthread.h> #import <Foundation/NSString.h> @@ -29,10 +31,12 @@ volatile unsigned long long maxpc; unsigned int lastReadAddr; - int membuf1_size; - int membuf2_size; - int membuf1_used; - int membuf2_used; + unsigned int keep_reading; + unsigned int load_addr; + volatile int membuf1_size; + volatile int membuf2_size; + volatile int membuf1_used; + volatile int membuf2_used; int16_t membuf1[kMemoryBufferSize]; int16_t membuf2[kMemoryBufferSize]; int curr_buf; Modified: FuckingFucker/FuckingFuckerView.h =================================================================== --- FuckingFucker/FuckingFuckerView.h 2010-07-28 18:11:44 UTC (rev 234) +++ FuckingFucker/FuckingFuckerView.h 2010-07-29 00:56:58 UTC (rev 235) @@ -9,6 +9,10 @@ IBOutlet NSTextView *machOutput; IBOutlet NSTextField *pidInputTextField; + + IBOutlet NSTextField *readAddrTextField; + + IBOutlet NSTextField *catchNameTextField; NSBitmapImageRep* renderBitmap; NSTimer* timer; @@ -22,6 +26,9 @@ - (IBAction)toggleSound:(id)sender; - (IBAction)toggleOSC:(id)sender; - (IBAction)changeSpeedControll:(id)sender; +- (IBAction)changeReadAddr:(id)sender; +- (IBAction)changeKeepReading:(id)sender; +- (IBAction)changeLoadAddr:(id)sender; - (IBAction)detachAll:(id)sender; - (IBAction)toggleSonifyOwnProcess:(id)sender; Modified: FuckingFucker/FuckingFuckerView.mm =================================================================== --- FuckingFucker/FuckingFuckerView.mm 2010-07-28 18:11:44 UTC (rev 234) +++ FuckingFucker/FuckingFuckerView.mm 2010-07-29 00:56:58 UTC (rev 235) @@ -3,6 +3,7 @@ #include "FuckingAudioIO.h" #import "StringTexture.h" + #include <unistd.h> @implementation FuckingFuckerView @@ -33,6 +34,10 @@ - (void)drawRect:(NSRect)rect { printf("draw\n"); + + if(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr || FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->keep_reading) + [readAddrTextField setStringValue:[NSString stringWithFormat:@"0x%08x",FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastReadAddr]]; + //open gl doesn't need to save restore cocntexts. // opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); // int16_t value; @@ -260,6 +265,7 @@ [[[machOutput textStorage] mutableString] deleteCharactersInRange:NSMakeRange(0,[[[machOutput textStorage] string] rangeOfString:@"\n"].location)]; } [poppedString release]; + [self setNeedsDisplay:YES]; } - (IBAction)toggleSound:(id)sender { @@ -284,11 +290,30 @@ { FuckingFuckerMan::Instance()->DetachAll(); } +- (IBAction)changeReadAddr:(id)sender +{ + unsigned int val; + if ( [[NSScanner scannerWithString:[sender stringValue]] scanHexInt:&val] ) { + FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastReadAddr = val; + + } +} +- (IBAction)changeKeepReading:(id)sender +{ + FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->keep_reading = [sender state] == NSOnState; +} +- (IBAction)changeLoadAddr:(id)sender +{ + FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->load_addr = [sender state] == NSOnState; + + [readAddrTextField setEditable:[sender state] != NSOnState]; + [readAddrTextField setSelectable:YES]; +} + - (IBAction)attachToProcess:(id)sender { - FuckingFuckerMan::Instance()->AttachToProcess([pidInputTextField intValue]); /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-28 18:11:52
|
Revision: 234 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=234&view=rev Author: mchinen Date: 2010-07-28 18:11:44 +0000 (Wed, 28 Jul 2010) Log Message: ----------- Memory listening 0.1 added Modified Paths: -------------- FuckingFucker/English.lproj/MainMenu.nib/classes.nib FuckingFucker/English.lproj/MainMenu.nib/info.nib FuckingFucker/English.lproj/MainMenu.nib/keyedobjects.nib FuckingFucker/FuckingAudioIO.cpp FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj FuckingFucker/FuckingFuckerMan.cpp FuckingFucker/FuckingFuckerMan.h FuckingFucker/FuckingFuckerView.h FuckingFucker/FuckingFuckerView.mm Modified: FuckingFucker/English.lproj/MainMenu.nib/classes.nib =================================================================== --- FuckingFucker/English.lproj/MainMenu.nib/classes.nib 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/English.lproj/MainMenu.nib/classes.nib 2010-07-28 18:11:44 UTC (rev 234) @@ -1,26 +1,55 @@ -{ - IBClasses = ( - {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, - { - ACTIONS = { - attachToProcess = id; - catchProcess = id; - changeSpeedControll = id; - detachAll = id; - sonifyAttachedProcess = id; - toggleOSC = id; - toggleSonifyOwnProcess = id; - toggleSound = id; - }; - CLASS = FuckingFuckerView; - LANGUAGE = ObjC; - OUTLETS = { - catchNameTextField = NSTextField; - machOutput = NSTextView; - pidInputTextField = NSTextField; - }; - SUPERCLASS = NSView; - } - ); - IBVersion = 1; -} \ No newline at end of file +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBClasses</key> + <array> + <dict> + <key>ACTIONS</key> + <dict> + <key>attachToProcess</key> + <string>id</string> + <key>catchProcess</key> + <string>id</string> + <key>changeSpeedControll</key> + <string>id</string> + <key>detachAll</key> + <string>id</string> + <key>sonifyAttachedProcess</key> + <string>id</string> + <key>toggleOSC</key> + <string>id</string> + <key>toggleSonifyOwnProcess</key> + <string>id</string> + <key>toggleSound</key> + <string>id</string> + </dict> + <key>CLASS</key> + <string>FuckingFuckerView</string> + <key>LANGUAGE</key> + <string>ObjC</string> + <key>OUTLETS</key> + <dict> + <key>catchNameTextField</key> + <string>NSTextField</string> + <key>machOutput</key> + <string>NSTextView</string> + <key>pidInputTextField</key> + <string>NSTextField</string> + </dict> + <key>SUPERCLASS</key> + <string>NSOpenGLView</string> + </dict> + <dict> + <key>CLASS</key> + <string>FirstResponder</string> + <key>LANGUAGE</key> + <string>ObjC</string> + <key>SUPERCLASS</key> + <string>NSObject</string> + </dict> + </array> + <key>IBVersion</key> + <string>1</string> +</dict> +</plist> Modified: FuckingFucker/English.lproj/MainMenu.nib/info.nib =================================================================== --- FuckingFucker/English.lproj/MainMenu.nib/info.nib 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/English.lproj/MainMenu.nib/info.nib 2010-07-28 18:11:44 UTC (rev 234) @@ -1,26 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>IBDocumentLocation</key> - <string>57 64 356 240 0 0 1024 746 </string> - <key>IBEditorPositions</key> - <dict> - <key>29</key> - <string>68 251 330 44 0 0 1024 746 </string> - </dict> <key>IBFramework Version</key> - <string>489.0</string> - <key>IBLockedObjects</key> - <array> - <integer>215</integer> - </array> + <string>680</string> + <key>IBLastKnownRelativeProjectPath</key> + <string>../FuckingFucker.xcodeproj</string> + <key>IBOldestOS</key> + <integer>5</integer> <key>IBOpenObjects</key> <array> - <integer>21</integer> <integer>29</integer> + <integer>2</integer> </array> <key>IBSystem Version</key> - <string>8S165</string> + <string>9L31a</string> + <key>targetFramework</key> + <string>IBCocoaFramework</string> </dict> </plist> Modified: FuckingFucker/English.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: FuckingFucker/FuckingAudioIO.cpp =================================================================== --- FuckingFucker/FuckingAudioIO.cpp 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/FuckingAudioIO.cpp 2010-07-28 18:11:44 UTC (rev 234) @@ -130,6 +130,42 @@ // memcpy(((float*)outputBuffer)+framesPerBuffer*z,noisearray+randint(framesPerBuffer*(noisefactor)),framesPerBuffer*sizeof(float)); delete [] noisearray; } + + opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); + int16_t *membuf = NULL; + int use_size; + int mem_out_cursor; + + if(analysis->curr_buf == 0 && analysis->membuf1_used < analysis->membuf1_size){ + use_size = mymin(framesPerBuffer, analysis->membuf1_size - analysis->membuf1_used); + membuf = analysis->membuf1 + analysis->membuf1_used; + //printf("using %i buf1\n",use_size); + } else if (analysis->curr_buf == 1 && analysis->membuf2_used < analysis->membuf2_size){ + use_size = mymin(framesPerBuffer, analysis->membuf2_size - analysis->membuf2_used); + membuf = analysis->membuf2 + analysis->membuf2_used; + + } + if(membuf) { + for(int i=0;i<use_size;i++) { + for( int z = 0; z < NUM_CHANNELS; z++ ) { + ((float*)outputBuffer)[i*NUM_CHANNELS+z] += membuf[i]/32768.0; + } + } + } + if(analysis->curr_buf == 0 && analysis->membuf1_used < analysis->membuf1_size){ + analysis->membuf1_used += use_size; + if(analysis->membuf1_used >= analysis->membuf1_size) + analysis->curr_buf = 1; + } + if(analysis->curr_buf == 1 && analysis->membuf2_used < analysis->membuf2_size){ + analysis->membuf2_used += use_size; + if(analysis->membuf2_used >= analysis->membuf2_size) + analysis->curr_buf = 0; + } + + + + // else // { // //zero it. Modified: FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj =================================================================== --- FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj 2010-07-28 18:11:44 UTC (rev 234) @@ -152,7 +152,7 @@ 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 32CA4F630368D1EE00C91783 /* FuckingFucker_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FuckingFucker_Prefix.pch; sourceTree = "<group>"; }; 3E6363E7116A265F0095817A /* 10.5 3264 uni-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "10.5 3264 uni-Info.plist"; sourceTree = "<group>"; }; - 3E636554116A28630095817A /* FuckingFucker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FuckingFucker.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 3E636554116A28630095817A /* lstn.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = lstn.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3E636556116A28640095817A /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Info copy.plist"; sourceTree = "<group>"; }; 84166E2811409F01004E3684 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; @@ -272,7 +272,7 @@ isa = PBXGroup; children = ( 8D1107320486CEB800E47090 /* FuckingFucker.app */, - 3E636554116A28630095817A /* FuckingFucker.app */, + 3E636554116A28630095817A /* lstn.app */, ); name = Products; sourceTree = "<group>"; @@ -376,7 +376,7 @@ name = FuckingFucker10.5; productInstallPath = "$(HOME)/Applications"; productName = FuckingFucker; - productReference = 3E636554116A28630095817A /* FuckingFucker.app */; + productReference = 3E636554116A28630095817A /* lstn.app */; productType = "com.apple.product-type.application"; }; 8D1107260486CEB800E47090 /* FuckingFucker */ = { @@ -567,7 +567,7 @@ LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3 = "\"$(SRCROOT)\""; ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH)"; - PRODUCT_NAME = FuckingFucker; + PRODUCT_NAME = lstn; SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; VALID_ARCHS = "x86_64 i386 ppc"; WRAPPER_EXTENSION = app; @@ -595,7 +595,7 @@ LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3 = "\"$(SRCROOT)\""; - PRODUCT_NAME = FuckingFucker; + PRODUCT_NAME = lstn; WRAPPER_EXTENSION = app; }; name = Release; @@ -662,6 +662,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; LINKER_DISPLAYS_MANGLED_NAMES = NO; PREBINDING = NO; + PRODUCT_NAME = lstn; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; }; name = Debug; @@ -676,6 +677,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.4; ONLY_LINK_ESSENTIAL_SYMBOLS = YES; PREBINDING = NO; + PRODUCT_NAME = lstn; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; VALID_ARCHS = "i386 ppc"; }; Modified: FuckingFucker/FuckingFuckerMan.cpp =================================================================== --- FuckingFucker/FuckingFuckerMan.cpp 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/FuckingFuckerMan.cpp 2010-07-28 18:11:44 UTC (rev 234) @@ -301,6 +301,9 @@ m_opAnalysis.bufstart=0; m_opAnalysis.buflen=kFFManAudioBufferSize; m_opAnalysis.mode=0; + m_opAnalysis.curr_buf = 0; + m_opAnalysis.lastReadAddr = 0xFFFFFFFF; + m_opAnalysis.membuf1_size = m_opAnalysis.membuf2_size = m_opAnalysis.membuf2_used = m_opAnalysis.membuf1_used = 0; m_audioBuffer=new float[kFFManAudioBufferSize]; @@ -710,7 +713,7 @@ //ignore ret opcodes if(info->opcodebyte == 0xC3) return -1; - printf("printed 32\n"); + //get the actual instruction bytecode unsigned long long opcode = 0; struct dis_private* dis_priv = &info->private_data; @@ -728,56 +731,105 @@ { printtimer=kPrintTimerFireMicros; - printf("attempt bt 32\n"); +#define kFFScanStart 0x00180000 + //right now this only works with one task + unsigned int scanAdd; + int tries =0; + int kr; + vm_size_t bytesRead; + + if(analysis->lastReadAddr == 0xFFFFFFFF) + { + analysis->lastReadAddr = kFFScanStart; + } + //find any pointer on heap. + if(analysis->membuf1_size <= analysis->membuf1_used) { + //try the next address. + kr = 1; + + scanAdd = analysis->lastReadAddr; + while(kr!=0 && tries++ < 10) { + tries = 0; + kr = vm_read_overwrite(port, (vm_address_t) scanAdd, (vm_size_t) kMemoryBufferSize * sizeof(*analysis->membuf1), (vm_address_t) analysis->membuf1, &bytesRead); + if(kr!=0) { + printf("scan fail %x",scanAdd); + scanAdd = coinflip()?kFFScanStart:randint(0x80000000); + } + } + + if(kr==0){ +// printf("scan ok %i",bytesRead); + analysis->membuf1_size = bytesRead/sizeof(*analysis->membuf1); + analysis->membuf1_used = 0; + analysis->lastReadAddr = scanAdd + bytesRead; + } + } else if(analysis->membuf2_size <= analysis->membuf2_used) { + scanAdd = analysis->lastReadAddr; + kr = 1; + while(kr!=0 && tries++ < 10) { + tries = 0; + kr = vm_read_overwrite(port, (vm_address_t) scanAdd, (vm_size_t) kMemoryBufferSize, (vm_address_t) analysis->membuf2, &bytesRead); + if(kr!=0) { + printf("scan fail %x",scanAdd); + scanAdd = coinflip()?kFFScanStart:randint(0x80000000); + } + } + + if(kr==0){ + analysis->membuf2_size = bytesRead/sizeof(*analysis->membuf2); + analysis->membuf2_used = 0; + analysis->lastReadAddr = scanAdd + bytesRead; + } + } + FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat:@"pc: 0x%X opcode:%qX byte:%.2X inst:(%s)\n",threadState.FUCKINGEIP,opcode,(int)info->opcodebyte, info->desc]); - //start backtrace - doesnt work for intel mac core2duo - //QSymbols testSymbols; - QBTFrame * frames; - size_t frameToAllocate; - size_t frameCount; - frameToAllocate = 10; - //testSymbols.didSuspend = true; - - - frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); - - int btres = QBacktraceMachThreadState( - port, - /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; - &threadState, - sizeof(i386_thread_state_t), - CPU_TYPE_X86,// QMOGetLocalCPUType(), - NULL,// &testSymbols,//symRef, - 0, - 0, - frames, - frameToAllocate, - &frameCount - ); - char* space; - space = (char*) malloc(frameToAllocate+1); - //fill it with holes - memset(space,' ',frameToAllocate); - //terminate it - space[frameToAllocate]=0; - - if(btres==0) - { - printf("btres ok\n",btres); - for(int i=0;i<mymin(frameCount,frameToAllocate);i++) - { - //adds indentation by using pointer arithmathic and the spaces string - FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: - @"%spc:%qX fp:%qX %s\n", - space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); - - } - }else - printf("btres err %d\n",btres); - free(space); - QBacktraceDisposeSymbols(frames,frameToAllocate); - // QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); - free(frames); + +// printf("attempt bt 32\n"); +// //start backtrace - doesnt work for intel mac core2duo +// QBTFrame * frames; +// size_t frameToAllocate; +// size_t frameCount; +// frameToAllocate = 10; +// +// frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); +// +// int btres = QBacktraceMachThreadState( +// port, +// /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; +// &threadState, +// sizeof(i386_thread_state_t), +// CPU_TYPE_X86,// QMOGetLocalCPUType(), +// NULL,// &testSymbols,//symRef, +// 0, +// 0, +// frames, +// frameToAllocate, +// &frameCount +// ); +// char* space; +// space = (char*) malloc(frameToAllocate+1); +// //fill it with holes +// memset(space,' ',frameToAllocate); +// //terminate it +// space[frameToAllocate]=0; +// +// if(btres==0) +// { +// printf("btres ok\n",btres); +// for(int i=0;i<mymin(frameCount,frameToAllocate);i++) +// { +// //adds indentation by using pointer arithmathic and the spaces string +// FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: +// @"%spc:%qX fp:%qX %s\n", +// space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); +// +// } +// }else +// printf("btres err %d\n",btres); +// free(space); +// QBacktraceDisposeSymbols(frames,frameToAllocate); +// free(frames); +// //end backtrace } Modified: FuckingFucker/FuckingFuckerMan.h =================================================================== --- FuckingFucker/FuckingFuckerMan.h 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/FuckingFuckerMan.h 2010-07-28 18:11:44 UTC (rev 234) @@ -13,6 +13,7 @@ #define MAX_NUM_ATTACHED_THREADS 5 #define kFFManAudioBufferSize 50000 +#define kMemoryBufferSize 32768 #include <pthread.h> #import <Foundation/NSString.h> @@ -26,6 +27,16 @@ volatile int lastreg; volatile unsigned long long minpc; volatile unsigned long long maxpc; + + unsigned int lastReadAddr; + int membuf1_size; + int membuf2_size; + int membuf1_used; + int membuf2_used; + int16_t membuf1[kMemoryBufferSize]; + int16_t membuf2[kMemoryBufferSize]; + int curr_buf; + } opcode_analysis; Modified: FuckingFucker/FuckingFuckerView.h =================================================================== --- FuckingFucker/FuckingFuckerView.h 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/FuckingFuckerView.h 2010-07-28 18:11:44 UTC (rev 234) @@ -10,7 +10,7 @@ IBOutlet NSTextField *pidInputTextField; IBOutlet NSTextField *catchNameTextField; - + NSBitmapImageRep* renderBitmap; NSTimer* timer; } - (id)initWithFrame:(NSRect)frame; Modified: FuckingFucker/FuckingFuckerView.mm =================================================================== --- FuckingFucker/FuckingFuckerView.mm 2010-07-27 21:38:51 UTC (rev 233) +++ FuckingFucker/FuckingFuckerView.mm 2010-07-28 18:11:44 UTC (rev 234) @@ -32,9 +32,44 @@ - (void)drawRect:(NSRect)rect { - + printf("draw\n"); //open gl doesn't need to save restore cocntexts. - +// opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); +// int16_t value; +// float grayValue; +// int width = [self frame].size.width; +// int height = [self frame].size.height; +// float y; +// float x; +// float pixPerSamp = width * height / kMemoryBufferSize; +// float gldxPerSamp = (pixPerSamp/height)*2; +// +// for(int i=0; i < kMemoryBufferSize;i++) { +// value = analysis->membuf1[i]; +// grayValue = (value +32786)/(32768*2); +// +// x = i*pixPerSamp; +// y = ((int) x)/(width); +// x = ((int)x)%width; +// +// x = x/width; +// x = (x-0.5) * 2; +// y = y/height; +// y = (0.5 - y) * 2; +// +// printf("x %f y %f dx %f\n",x,y,gldxPerSamp); +// glBegin( GL_LINES ); +// { +// glColor4f(grayValue,grayValue,grayValue,1.0); +// glVertex3f(x, y, 0.0f ); +// +// glVertex3f(x+gldxPerSamp, y, 0.0f ); +// } +// glEnd(); +// +// glDisable(GL_BLEND); // for text fading +// +// } } - (void) eraseActivityText:(float)textY height:(float)textHeight @@ -168,6 +203,42 @@ selector: @selector(refreshText) userInfo:nil repeats: YES]; + + NSRect frame; + frame = [self frame]; + renderBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil + pixelsWide:frame.size.width + pixelsHigh:frame.size.height + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bitmapFormat:(NSBitmapFormat)0 + bytesPerRow:4*frame.size.width + bitsPerPixel:32]; + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:renderBitmap]]; + + + //make it white. + unsigned char* bitmap = [renderBitmap bitmapData]; + int i,j; + for(i=0;i<[renderBitmap pixelsHigh];i++) + { + for( j =0;j<[renderBitmap pixelsWide];j++) + { + //white + *bitmap++ = 255;//R + *bitmap++ = 255;//G + *bitmap++ = 255;//B + *bitmap++ = 255; + } + } + + + [NSGraphicsContext restoreGraphicsState]; + } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-27 21:38:59
|
Revision: 233 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=233&view=rev Author: mchinen Date: 2010-07-27 21:38:51 +0000 (Tue, 27 Jul 2010) Log Message: ----------- x86 debugging for boinc backtrace (still not working) Modified Paths: -------------- FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj FuckingFucker/FuckingFuckerMan.cpp FuckingFucker/OscMan.mm FuckingFucker/boincbacktrace/QBacktrace.c FuckingFucker/boincbacktrace/QMachOImage.c FuckingFucker/boincbacktrace/QMachOImageList.c FuckingFucker/boincbacktrace/QSymbols.c FuckingFucker/boincbacktrace/QTaskMemory.c FuckingFucker/boincbacktrace/QTaskMemory.h Modified: FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj =================================================================== --- FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj 2010-07-25 19:12:39 UTC (rev 232) +++ FuckingFucker/FuckingFucker.xcodeproj/project.pbxproj 2010-07-27 21:38:51 UTC (rev 233) @@ -65,6 +65,8 @@ 3E63654E116A28630095817A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84166E2811409F01004E3684 /* Security.framework */; }; 3E63654F116A28630095817A /* liblo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 18D4C70A1153ED4F0087A465 /* liblo.a */; }; 84166E2911409F01004E3684 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84166E2811409F01004E3684 /* Security.framework */; }; + 84EAAAFE11AC00EF00223A1C /* StringTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B445A2117391D60035337F /* StringTexture.m */; }; + 84EAAB1211AC017100223A1C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18B44901117764650035337F /* OpenGL.framework */; }; 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; @@ -149,9 +151,9 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 32CA4F630368D1EE00C91783 /* FuckingFucker_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FuckingFucker_Prefix.pch; sourceTree = "<group>"; }; - 3E6363E7116A265F0095817A /* 10.5 3264 uni-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = file; path = "10.5 3264 uni-Info.plist"; sourceTree = "<group>"; }; + 3E6363E7116A265F0095817A /* 10.5 3264 uni-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "10.5 3264 uni-Info.plist"; sourceTree = "<group>"; }; 3E636554116A28630095817A /* FuckingFucker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FuckingFucker.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 3E636556116A28640095817A /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Info copy.plist"; sourceTree = "<group>"; }; + 3E636556116A28640095817A /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Info copy.plist"; sourceTree = "<group>"; }; 84166E2811409F01004E3684 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D1107320486CEB800E47090 /* FuckingFucker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FuckingFucker.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -162,6 +164,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 84EAAB1211AC017100223A1C /* OpenGL.framework in Frameworks */, 3E636548116A28630095817A /* Cocoa.framework in Frameworks */, 3E636549116A28630095817A /* libportaudio.a in Frameworks */, 3E63654A116A28630095817A /* AudioToolbox.framework in Frameworks */, @@ -492,6 +495,7 @@ 3E636544116A28630095817A /* QSymbols.c in Sources */, 3E636545116A28630095817A /* QTaskMemory.c in Sources */, 3E636546116A28630095817A /* OscMan.mm in Sources */, + 84EAAAFE11AC00EF00223A1C /* StringTexture.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -544,15 +548,14 @@ 3E636552116A28630095817A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)"; - ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64"; + ARCHS = "$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)"; ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; - INFOPLIST_FILE = "/Users/miyazaki/Documents/Xcode-workfolder/svnAlgorhythmics/FuckingFucker/Info copy.plist"; + INFOPLIST_FILE = "Info copy.plist"; INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -563,6 +566,7 @@ LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3 = "\"$(SRCROOT)\""; + ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH)"; PRODUCT_NAME = FuckingFucker; SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; VALID_ARCHS = "x86_64 i386 ppc"; @@ -580,7 +584,7 @@ ); GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_MODEL_TUNING = G5; - INFOPLIST_FILE = "/Users/miyazaki/Documents/Xcode-workfolder/svnAlgorhythmics/FuckingFucker/Info copy.plist"; + INFOPLIST_FILE = "Info copy.plist"; INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -665,16 +669,15 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - ); + ARCHS = "$(NATIVE_ARCH)"; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; LINKER_DISPLAYS_MANGLED_NAMES = NO; + MACOSX_DEPLOYMENT_TARGET = 10.4; ONLY_LINK_ESSENTIAL_SYMBOLS = YES; PREBINDING = NO; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + VALID_ARCHS = "i386 ppc"; }; name = Release; }; Modified: FuckingFucker/FuckingFuckerMan.cpp =================================================================== --- FuckingFucker/FuckingFuckerMan.cpp 2010-07-25 19:12:39 UTC (rev 232) +++ FuckingFucker/FuckingFuckerMan.cpp 2010-07-27 21:38:51 UTC (rev 233) @@ -53,20 +53,20 @@ int targetPID; int token; - void* thread_state;//can be ppc_thread_state_t or i386_thread_state_t - void* float_state; - - void* priv;//for things such as i386_dissasemble_info which need function pointers inited - - void (*pf_get_thread_state)(thread_act_t , void*,mach_msg_type_number_t*); - void (*pf_get_float_state)(thread_act_t , void*,mach_msg_type_number_t*); - void (*pf_set_taskport)(void* , task_t); - - void (*pf_cleanup_attach_data)(struct attach_data* data) ; - - int (*pf_analyze_state)(task_t&,void*,void*,void*,int &); -// ppc_thread_state_t ppc_state; -// ppc_float_state_t ppcfloat_state; + void* thread_state;//can be ppc_thread_state_t or i386_thread_state_t + void* float_state; + + void* priv;//for things such as i386_dissasemble_info which need function pointers inited + + void (*pf_get_thread_state)(thread_act_t , void*,mach_msg_type_number_t*); + void (*pf_get_float_state)(thread_act_t , void*,mach_msg_type_number_t*); + void (*pf_set_taskport)(void* , task_t); + + void (*pf_cleanup_attach_data)(struct attach_data* data) ; + + int (*pf_analyze_state)(task_t&,void*,void*,void*,int &); + // ppc_thread_state_t ppc_state; + // ppc_float_state_t ppcfloat_state; }; @@ -74,34 +74,34 @@ int ppcAnalyzeState(task_t&,void*, void*,void*, int& ); int i386AnalyzeState(task_t&,void*, void*,void*, int& ); int i386_64AnalyzeState(task_t&,void*, void*,void*, int& ); - + //functions to be used with function pointers for arch specific mach params void ppcGetThreadState(thread_act_t target_thread, void* ppc_state,mach_msg_type_number_t* psc) { - *psc=PPC_THREAD_STATE_COUNT; + *psc=PPC_THREAD_STATE_COUNT; if(KERN_SUCCESS!=thread_get_state( target_thread, - PPC_THREAD_STATE, - (thread_state_t)ppc_state, - psc - )) + PPC_THREAD_STATE, + (thread_state_t)ppc_state, + psc + )) { - FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: - @"failed to read thread state\n"]); + FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: + @"failed to read thread state\n"]); } } void ppcGetFloatState(thread_act_t target_thread , void* ppc_state,mach_msg_type_number_t* psc) { - *psc=PPC_FLOAT_STATE_COUNT; - thread_get_state( target_thread, - PPC_FLOAT_STATE, - (thread_state_t)ppc_state, - psc - ); + *psc=PPC_FLOAT_STATE_COUNT; + thread_get_state( target_thread, + PPC_FLOAT_STATE, + (thread_state_t)ppc_state, + psc + ); } void ppc_cleanup_attach_data(struct attach_data* data) { - delete (ppc_thread_state_t*)data->thread_state; - delete (ppc_float_state_t*)data->float_state; + delete (ppc_thread_state_t*)data->thread_state; + delete (ppc_float_state_t*)data->float_state; } //not used @@ -121,26 +121,26 @@ void i386GetThreadState(thread_act_t target_thread, void* ppc_state,mach_msg_type_number_t* psc) { - *psc=i386_THREAD_STATE_COUNT; - thread_get_state( target_thread, - i386_THREAD_STATE, - (thread_state_t)ppc_state, - psc - ); + *psc=i386_THREAD_STATE_COUNT; + thread_get_state( target_thread, + i386_THREAD_STATE, + (thread_state_t)ppc_state, + psc + ); } void i386GetFloatState(thread_act_t target_thread , void* ppc_state,mach_msg_type_number_t* psc) { - *psc=i386_FLOAT_STATE_COUNT; - thread_get_state( target_thread, - i386_FLOAT_STATE, - (thread_state_t)ppc_state, - psc - ); + *psc=i386_FLOAT_STATE_COUNT; + thread_get_state( target_thread, + i386_FLOAT_STATE, + (thread_state_t)ppc_state, + psc + ); } void i386_cleanup_attach_data(struct attach_data* data) { - delete (i386_thread_state_t*)data->thread_state; - delete (i386_float_state_t*)data->float_state; + delete (i386_thread_state_t*)data->thread_state; + delete (i386_float_state_t*)data->float_state; } void i386_set_taskport(void* data, task_t port) { @@ -156,12 +156,12 @@ data->thread_state = new i386_thread_state_t; data->float_state = new i386_float_state_t; data->pf_set_taskport=i386_set_taskport; - + //disasembly init data->priv = new disassemble_info_i386; init_disassemble_info_i386((disassemble_info_i386*)data->priv); ((disassemble_info_i386*)data->priv)->mach = bfd_mach_i386_i386; - + } //for 64 bit intel (core 2 duo, i3/5/7, but not core duo) @@ -169,26 +169,26 @@ void i386_64GetThreadState(thread_act_t target_thread, void* ppc_state,mach_msg_type_number_t* psc) { - *psc=x86_THREAD_STATE64_COUNT; - thread_get_state( target_thread, - x86_THREAD_STATE64, - (thread_state_t)ppc_state, - psc - ); + *psc=x86_THREAD_STATE64_COUNT; + thread_get_state( target_thread, + x86_THREAD_STATE64, + (thread_state_t)ppc_state, + psc + ); } void i386_64GetFloatState(thread_act_t target_thread , void* ppc_state,mach_msg_type_number_t* psc) { - *psc=x86_FLOAT_STATE64_COUNT; - thread_get_state( target_thread, - x86_FLOAT_STATE64, - (thread_state_t)ppc_state, - psc - ); + *psc=x86_FLOAT_STATE64_COUNT; + thread_get_state( target_thread, + x86_FLOAT_STATE64, + (thread_state_t)ppc_state, + psc + ); } void i386_64_cleanup_attach_data(struct attach_data* data) { - delete (x86_thread_state64_t*)data->thread_state; - delete (x86_float_state64_t*)data->float_state; + delete (x86_thread_state64_t*)data->thread_state; + delete (x86_float_state64_t*)data->float_state; } void i386_64_init_attach_data(struct attach_data* data) @@ -201,7 +201,7 @@ data->thread_state = new x86_thread_state64_t; data->float_state = new x86_float_state64_t; data->pf_set_taskport=i386_set_taskport; //uses 32bit version. - + //disasembly init data->priv = new disassemble_info_i386; //we just have to hope this works using the same 32bit calls. @@ -211,8 +211,8 @@ struct catch_data{ - char bsd_name[100]; - int timeout_secs; + char bsd_name[100]; + int timeout_secs; }; @@ -232,53 +232,57 @@ { m_view = NULL; } - + FuckingFuckerMan::~FuckingFuckerMan() { - + pthread_mutex_destroy(&m_outViewMutex); } int acquireTaskportRight() { - // AuthorizationRef authorization; -// OSStatus status = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorization); -// if (status != 0) { -// fprintf(stderr, "Error creating authorization reference\n"); -// return -1; -// } -// AuthorizationItem right = { "system.privilege.taskport", 0, 0 , 0 }; -// AuthorizationItem items[] = {right }; -// AuthorizationRights rights = { sizeof(items) / sizeof(items[0]), items }; -// AuthorizationFlags flags = kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize; -// -// status = AuthorizationCopyRights (authorization, &rights, kAuthorizationEmptyEnvironment, flags, NULL); -// if (status != 0) { -// fprintf(stderr, "Error authorizing current process with right to call task_for_pid\n"); -// return -1; -// } -// return 0; + // AuthorizationRef authorization; + // OSStatus status = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorization); + // if (status != 0) { + // fprintf(stderr, "Error creating authorization reference\n"); + // return -1; + // } + // AuthorizationItem right = { "system.privilege.taskport", 0, 0 , 0 }; + // AuthorizationItem items[] = {right }; + // AuthorizationRights rights = { sizeof(items) / sizeof(items[0]), items }; + // AuthorizationFlags flags = kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize; + // + // status = AuthorizationCopyRights (authorization, &rights, kAuthorizationEmptyEnvironment, flags, NULL); + // if (status != 0) { + // fprintf(stderr, "Error authorizing current process with right to call task_for_pid\n"); + // return -1; + // } + // printf("auth successful \n"); + // return 0; - OSStatus stat; - AuthorizationItem taskport_item[] = {{"system.privilege.taskport"}}; - AuthorizationRights rights = {1, taskport_item}, *out_rights = NULL; - AuthorizationRef author; - int retval = 0; - - AuthorizationFlags auth_flags = kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize | kAuthorizationFlagInteractionAllowed | ( 1 << 5); - - stat = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment,auth_flags,&author); - + printf("try"); + OSStatus stat; + AuthorizationItem taskport_item[] = {{"system.privilege.taskport"}}; + AuthorizationRights rights = {1, taskport_item}, *out_rights = NULL; + AuthorizationRef author; + + AuthorizationFlags auth_flags = kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize | kAuthorizationFlagInteractionAllowed | ( 1 << 5); + + stat = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment,auth_flags,&author); + if (stat != errAuthorizationSuccess) { - return 0; - } - - stat = AuthorizationCopyRights ( author, &rights, kAuthorizationEmptyEnvironment, auth_flags,&out_rights); - - if (stat != errAuthorizationSuccess) { - printf("fail"); - return 1; - } - return 0; + printf("fail\n"); + return -1; + } + + stat = AuthorizationCopyRights ( author, &rights, kAuthorizationEmptyEnvironment, auth_flags,&out_rights); + + if (stat != errAuthorizationSuccess) { + printf("fail"); + return -1; + } + printf("ok\n"); + return 0; + } void FuckingFuckerMan::Init() { @@ -287,7 +291,7 @@ //pthread_mutex_t m_outViewMutex; pthread_mutex_init (&m_outViewMutex, NULL); m_outputString = @""; - + m_oscOn = false; m_speedControl=1.0;//full speed. m_opAnalysis.minpc = 0xFFFFFFF; @@ -302,20 +306,22 @@ FuckingAudioIO::Instance()->Init(); m_attachToken=0;//counter. - + + printf("init"); //for 10.4.[6+) intel and 10.5 ppc and above we need some probably smart permission in order to get //calls like tassk_for_pid to work since they can be used for hacking. - if(acquireTaskportRight() ==-1) + if(acquireTaskportRight() == -1) { - //we failed, so quit. - + //we failed, so quit. + + printf("failed\n"); } - -// [[OscMan sharedMan] addIP:"192.168.0.16"]; -// [[OscMan sharedMan] addIP:"127.0.0.1"]; - - + // [[OscMan sharedMan] addIP:"192.168.0.16"]; + // [[OscMan sharedMan] addIP:"127.0.0.1"]; + + + } @@ -335,13 +341,13 @@ { if(pid ==0) return; - + struct attach_data* data = new attach_data; //start the sound if we haven't yet if(!FuckingAudioIO::Instance()->IsStarted()) FuckingAudioIO::Instance()->Start(); - + data->targetPID=pid; data->token = m_attachToken; @@ -355,18 +361,18 @@ int err; task_t task; cpu_type_t cputype; - bool is64Bit; - + bool is64Bit = false; + err = task_for_pid(mach_task_self(), pid, &task); //TODO:are we leaking this? //first attempt 32 bit. if that fails, do 64 err = QMOImageCreateFromTaskDyld(task, CPU_TYPE_X86, &dyld); if(!dyld) - err = QMOImageCreateFromTaskDyld(task, CPU_TYPE_X86_64, &dyld); + err = QMOImageCreateFromTaskDyld(task, CPU_TYPE_X86_64, &dyld); is64Bit = IsTask64Bit(dyld); QMOImageDestroy(dyld); - + if(is64Bit) i386_64_init_attach_data(data); else @@ -380,35 +386,35 @@ //launch a thread that processes this shit. pthread_create(&attachedThreads[0],//TODO: take input number for index - NULL,//const pthread_attr_t *restrict attr, - attachProcessHelper, - data);// void *restrict arg) + NULL,//const pthread_attr_t *restrict attr, + attachProcessHelper, + data);// void *restrict arg) } void FuckingFuckerMan::CatchProcess(const char* bsdName,int timeout_secs) { - struct catch_data* data = new catch_data; - strcpy(data->bsd_name, bsdName); - data->timeout_secs=timeout_secs; - pthread_create(&attachedThreads[0],//TODO: take input number for index - NULL,//const pthread_attr_t *restrict attr, - catchProcessHelper, - data);// void *restrict arg) + struct catch_data* data = new catch_data; + strcpy(data->bsd_name, bsdName); + data->timeout_secs=timeout_secs; + pthread_create(&attachedThreads[0],//TODO: take input number for index + NULL,//const pthread_attr_t *restrict attr, + catchProcessHelper, + data);// void *restrict arg) } void FuckingFuckerMan::AppendToOutput(NSString* inputString) { - NSString* temp; - //this will append the input to this member string. Creates a new reference, so we have to be careful. + NSString* temp; + //this will append the input to this member string. Creates a new reference, so we have to be careful. pthread_mutex_lock (&m_outViewMutex); temp=m_outputString; m_outputString = [m_outputString stringByAppendingString:inputString]; -// [NSString stringWithString:inputString]];// encoding:NSASCIIStringEncoding ] ]; + // [NSString stringWithString:inputString]];// encoding:NSASCIIStringEncoding ] ]; [temp release]; [m_outputString retain]; pthread_mutex_unlock (&m_outViewMutex); - + } NSString* FuckingFuckerMan::PopOutput() @@ -428,34 +434,34 @@ void *catchProcessHelper(void* arg) { int pid; - int err; + int err; unsigned long elapsed = 0; [[NSAutoreleasePool alloc] init]; //attach_data has info about which process to attach to and how to sample its registers. struct catch_data* cat = (catch_data*) arg; - - + + //sit and wait until the process launches. while(elapsed/1000000 < cat->timeout_secs) { - //try to find a pid for the name. - pid = GetPIDForProcessName(cat->bsd_name); - if(pid>=0) - break; + //try to find a pid for the name. + pid = GetPIDForProcessName(cat->bsd_name); + if(pid>=0) + break; usleep(kCatchDelayMicros); elapsed+= kCatchDelayMicros; } if(pid>=0) { - //we got a pid - so attach to it. - FuckingFuckerMan::Instance()->AttachToProcess( pid); - FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"Caught %s\n",cat->bsd_name]); - + //we got a pid - so attach to it. + FuckingFuckerMan::Instance()->AttachToProcess( pid); + FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"Caught %s\n",cat->bsd_name]); + } else if(elapsed/1000000 >= cat->timeout_secs) { - FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"Catch for %s timed out\n",cat->bsd_name]); + FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"Catch for %s timed out\n",cat->bsd_name]); } delete cat; } @@ -524,15 +530,15 @@ // unsigned int fpscr; /* floating point status register */ //}; - //thread_set_exception_ports() - enable single stepping - // we can get single step by bit ORing the 0x400UL bit to the srr0 (PC) register. for ppc i guess +//thread_set_exception_ports() - enable single stepping +// we can get single step by bit ORing the 0x400UL bit to the srr0 (PC) register. for ppc i guess #define kOpDelayMicros 5000 #define kPrintTimerFireMicros 100000 //#define kPrintTimerFireMicros 1000000 //returns -1 if no error int ppcAnalyzeState(task_t& port, void* thread_state, void* float_state, void* priv, int & printtimer) { - + ppc_thread_state_t& ppc_state=*((ppc_thread_state_t*)thread_state); ppc_float_state_t& ppcfloat_state=*((ppc_float_state_t*)float_state); //from boinc mac_backtrace.C/H (LGPL): this is how we can get the instruction code @@ -545,9 +551,9 @@ sizeRead = sizeof(instruction); - + err = vm_read_overwrite(port,(vm_address_t) ppc_state.FUCKINGSRR0, sizeof(instruction), (vm_address_t) &instruction, &sizeRead); - + if ( (err == 0) && (sizeRead == sizeof(instruction)) ) { err = -1; } @@ -555,64 +561,65 @@ { return err; } - - - + + + printf("attempt decode ppc\n"); + if(err==-1 && instruction!=0x4E800020) { - - //QSymbols testSymbols; - QBTFrame * frames; - size_t frameToAllocate; - size_t frameCount; - - frameToAllocate = 10; - //testSymbols.didSuspend = true; - - frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); - - int btres = QBacktraceMachThreadState( - port, - /*flavor = */PPC_THREAD_STATE, //x86_THREAD_STATE32; - &ppc_state, - sizeof(ppc_thread_state_t), - CPU_TYPE_POWERPC,// QMOGetLocalCPUType(), - NULL,// &testSymbols,//symRef, - 0, - 0, - frames, - frameToAllocate, - &frameCount - ); - char* space; - space = (char*) malloc(frameToAllocate+1); - //fill it with holes - memset(space,' ',frameToAllocate); - //terminate it - space[frameToAllocate]=0; - if(btres==0 && printtimer<0) - { - for(int i=0;i<mymin(frameCount,frameToAllocate);i++) + //QSymbols testSymbols; + QBTFrame * frames; + size_t frameToAllocate; + size_t frameCount; + + frameToAllocate = 10; + //testSymbols.didSuspend = true; + + + frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); + + int btres = QBacktraceMachThreadState( + port, + /*flavor = */PPC_THREAD_STATE, //x86_THREAD_STATE32; + &ppc_state, + sizeof(ppc_thread_state_t), + CPU_TYPE_POWERPC,// QMOGetLocalCPUType(), + NULL,// &testSymbols,//symRef, + 0, + 0, + frames, + frameToAllocate, + &frameCount + ); + char* space; + space = (char*) malloc(frameToAllocate+1); + //fill it with holes + memset(space,' ',frameToAllocate); + //terminate it + space[frameToAllocate]=0; + if(btres==0 && printtimer<0) { - //adds indentation by using pointer arithmathic and the spaces string - FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: - @"%spc:%qX fp:%qX %s\n",// %s\n", - space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); + for(int i=0;i<mymin(frameCount,frameToAllocate);i++) + { + //adds indentation by using pointer arithmathic and the spaces string + FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: + @"%spc:%qX fp:%qX %s\n",// %s\n", + space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); + + } + } + free(space); + QBacktraceDisposeSymbols(frames,frameToAllocate); + // QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); + free(frames); - } - } - free(space); - QBacktraceDisposeSymbols(frames,frameToAllocate); -// QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); - free(frames); - - /* - the format of these instructions is that the first few bits (length varies on instruction, i.e. bits 0-5) - contain info about which group of instructions and the last few bits (e.g. 22-31) specify which instruction from the - group. The remaining bits in the middle are used to specify which registers are inputs and possibly other instruction arguments. - It's too damn complicated so we use a dissasembler with bad spelling. - */ + /* + the format of these instructions is that the first few bits (length varies on instruction, i.e. bits 0-5) + contain info about which group of instructions and the last few bits (e.g. 22-31) specify which instruction from the + group. The remaining bits in the middle are used to specify which registers are inputs and possibly other instruction arguments. + It's too damn complicated so we use a dissasembler with bad spelling. + */ dissasemble_insn_powerpc (instruction, &info, @@ -623,7 +630,7 @@ { printtimer=kPrintTimerFireMicros; FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat:@"pc: 0x%X(%f) inst: 0x%X( %s, %X) stacksize:%i\n",ppc_state.FUCKINGSRR0,analysis->cursor,instruction,info.name,info.opval,frameCount]); - + } //turn it into a sample and insert it into the sound manager. //the op alone ranges from 0-0x3f (0-191) @@ -640,56 +647,58 @@ //send instruction to the osc guy if(FuckingFuckerMan::Instance()->IsOSCOn()) [[OscMan sharedMan] sendDiracWithPan:analysis->cursor]; - + analysis->phase = ((float)info.opval/191.0)*M_PI; analysis->freq = 0.1+exp2cursor((float)info.opval/191.0)*5.0;//allow aliasing. - analysis->buflen =((float)info.opval/191.0)*kFFManAudioBufferSize*0.5+512; - //analysis->bufstart = randfloat(mymin(1.0,analysis->cursor+0.3))*(kFFManAudioBufferSize-analysis->buflen); - + analysis->buflen =((float)info.opval/191.0)*kFFManAudioBufferSize*0.5+512; + //analysis->bufstart = randfloat(mymin(1.0,analysis->cursor+0.3))*(kFFManAudioBufferSize-analysis->buflen); + analysis->bufstart = randint(kFFManAudioBufferSize-analysis->buflen); - analysis->mode = info.opval%4;//4 modes - - for(int j=0;j<info.numoperands;j++) - { - struct powerpc_operand *operand; - long value; //holds the register number or the absolute value if one is specified - operand = &info.operands[j]; - value = operand_value_powerpc (operand, instruction, 1); - if ((operand->flags & PPC_OPERAND_GPR) != 0 - || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) - { - //convert the unsigned int at the register to a float from -1.0 to 1.0 - FuckingFuckerMan::Instance()->SetBufferValue( FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart/*+randint(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen)*/, - /* (float)((*(&ppc_state.r0)+value)-INT_MAX)/INT_MAX * */coinflip()?1.0:-1.0 ); - FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastreg= *((&ppc_state.FUCKINGR0)+value); - } - } + analysis->mode = info.opval%4;//4 modes + + for(int j=0;j<info.numoperands;j++) + { + struct powerpc_operand *operand; + long value; //holds the register number or the absolute value if one is specified + operand = &info.operands[j]; + value = operand_value_powerpc (operand, instruction, 1); + if ((operand->flags & PPC_OPERAND_GPR) != 0 + || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) + { + //convert the unsigned int at the register to a float from -1.0 to 1.0 + FuckingFuckerMan::Instance()->SetBufferValue( FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart/*+randint(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen)*/, + /* (float)((*(&ppc_state.r0)+value)-INT_MAX)/INT_MAX * */coinflip()?1.0:-1.0 ); + FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastreg= *((&ppc_state.FUCKINGR0)+value); + } + } } return -1; } /*struct dis_private { - // Points to first byte not fetched. - bfd_byte *max_fetched; - bfd_byte the_buffer[MAX_MNEM_SIZE]; - bfd_vma insn_start; - int orig_sizeflag; - jmp_buf bailout; - - task_t task; -};*/ + // Points to first byte not fetched. + bfd_byte *max_fetched; + bfd_byte the_buffer[MAX_MNEM_SIZE]; + bfd_vma insn_start; + int orig_sizeflag; + jmp_buf bailout; + + task_t task; + };*/ int i386AnalyzeState(task_t& port, void* thread_state, void* float_state, void* priv, int & printtimer) { - struct attach_data& attach = *((struct attach_data*)priv) ; + struct attach_data& attach = *((struct attach_data*)priv) ; disassemble_info_i386* info = (disassemble_info_i386* ) attach.priv; - + i386_thread_state_t& threadState = *((i386_thread_state_t*) thread_state); i386_float_state_t& floatState = *((i386_float_state_t*) float_state); //it appears there are several really boring eip/pc values that are constant for all programs - skip these if(threadState.FUCKINGEIP == 0x90009CD7 || threadState.FUCKINGEIP == 0x900248C7 || threadState.FUCKINGEIP == 0x90037B57 - || threadState.FUCKINGEIP == 0x90047DD7 || threadState.FUCKINGEIP == 0x900248C7) + || threadState.FUCKINGEIP == 0x90047DD7 || threadState.FUCKINGEIP == 0x900248C7 || + threadState.FUCKINGEIP == 0x97CB644E || + threadState.FUCKINGEIP == 0x97CDF9C6 || threadState.FUCKINGEIP == 0x97CFE6FA) return -1; //reset the print cursor @@ -697,9 +706,11 @@ if(print_insn (threadState.FUCKINGEIP, info)>0) { - //ignore ret opcodes + + //ignore ret opcodes if(info->opcodebyte == 0xC3) return -1; + printf("printed 32\n"); //get the actual instruction bytecode unsigned long long opcode = 0; struct dis_private* dis_priv = &info->private_data; @@ -709,60 +720,66 @@ opcode+=dis_priv->the_buffer[i]; opcode= opcode << 8; } - - opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); + + + opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); + if(printtimer<0) { printtimer=kPrintTimerFireMicros; + + printf("attempt bt 32\n"); FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat:@"pc: 0x%X opcode:%qX byte:%.2X inst:(%s)\n",threadState.FUCKINGEIP,opcode,(int)info->opcodebyte, info->desc]); -//start backtrace - doesnt work for intel mac core2duo -// //QSymbols testSymbols; -// QBTFrame * frames; -// size_t frameToAllocate; -// size_t frameCount; -// frameToAllocate = 15; -// //testSymbols.didSuspend = true; -// -// -//frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); -// -// -// int btres = QBacktraceMachThreadState( -// port, -// /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; -// &threadState, -// sizeof(i386_thread_state_t), -// CPU_TYPE_X86,// QMOGetLocalCPUType(), -// NULL,// &testSymbols,//symRef, -// 0, -// 0, -// frames, -// frameToAllocate, -// &frameCount -// ); -// char* space; -// space = (char*) malloc(frameToAllocate+1); -// //fill it with holes -// memset(space,' ',frameToAllocate); -// //terminate it -// space[frameToAllocate]=0; -// if(btres==0) -// { -// for(int i=0;i<mymin(frameCount,frameToAllocate);i++) -// { -// //adds indentation by using pointer arithmathic and the spaces string -// FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: -// @"%spc:%qX fp:%qX %s %s\n", -// space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)",frames[i].library?frames[i].library:"" ]); -// -// } -// } -// free(space); -// QBacktraceDisposeSymbols(frames,frameToAllocate); -//// QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); -// free(frames); -////end backtrace - + //start backtrace - doesnt work for intel mac core2duo + //QSymbols testSymbols; + QBTFrame * frames; + size_t frameToAllocate; + size_t frameCount; + frameToAllocate = 10; + //testSymbols.didSuspend = true; + + + frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); + + int btres = QBacktraceMachThreadState( + port, + /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; + &threadState, + sizeof(i386_thread_state_t), + CPU_TYPE_X86,// QMOGetLocalCPUType(), + NULL,// &testSymbols,//symRef, + 0, + 0, + frames, + frameToAllocate, + &frameCount + ); + char* space; + space = (char*) malloc(frameToAllocate+1); + //fill it with holes + memset(space,' ',frameToAllocate); + //terminate it + space[frameToAllocate]=0; + + if(btres==0) + { + printf("btres ok\n",btres); + for(int i=0;i<mymin(frameCount,frameToAllocate);i++) + { + //adds indentation by using pointer arithmathic and the spaces string + FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: + @"%spc:%qX fp:%qX %s\n", + space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)"]);//,frames[i].library?frames[i].library:"" ]); + + } + }else + printf("btres err %d\n",btres); + free(space); + QBacktraceDisposeSymbols(frames,frameToAllocate); + // QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); + free(frames); + //end backtrace + } //turn it into a sample and insert it into the sound manager. //the op alone ranges from 0-0x3f (0-191) @@ -778,52 +795,53 @@ analysis->cursor = (float) (threadState.FUCKINGEIP-analysis->minpc)/analysis->maxpc; analysis->phase = ((float)info->opcodebyte/256.0)*M_PI; analysis->freq = 0.1+exp2cursor((float)info->opcodebyte/256.0)*5.0;//allow aliasing. - analysis->buflen =((float)info->opcodebyte/256.0)*kFFManAudioBufferSize*0.5+512; - //analysis->bufstart = randfloat(mymin(1.0,analysis->cursor+0.3))*(kFFManAudioBufferSize-analysis->buflen); - - FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart = randint(kFFManAudioBufferSize-FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen); - analysis->mode = info->opcodebyte%4;//4 modes - - //for(int j=0;j<info.numoperands;j++) -// { -// struct powerpc_operand *operand; -// long value; //holds the register number or the absolute value if one is specified -// operand = &info.operands[j]; -// value = operand_value_powerpc (operand, instruction, 1); -// if ((operand->flags & PPC_OPERAND_GPR) != 0 -// || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) -// { -// //convert the unsigned int at the register to a float from -1.0 to 1.0 -// FuckingFuckerMan::Instance()->SetBufferValue( FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart/*+randint(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen)*/, -// /* (float)((*(&ppc_state.r0)+value)-INT_MAX)/INT_MAX * */coinflip()?1.0:-1.0 ); -// FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastreg= *((&ppc_state.r0)+value); -// } -// } -// + analysis->buflen =((float)info->opcodebyte/256.0)*kFFManAudioBufferSize*0.5+512; + //analysis->bufstart = randfloat(mymin(1.0,analysis->cursor+0.3))*(kFFManAudioBufferSize-analysis->buflen); + + FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart = randint(kFFManAudioBufferSize-FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen); + analysis->mode = info->opcodebyte%4;//4 modes + + //for(int j=0;j<info.numoperands;j++) + // { + // struct powerpc_operand *operand; + // long value; //holds the register number or the absolute value if one is specified + // operand = &info.operands[j]; + // value = operand_value_powerpc (operand, instruction, 1); + // if ((operand->flags & PPC_OPERAND_GPR) != 0 + // || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) + // { + // //convert the unsigned int at the register to a float from -1.0 to 1.0 + // FuckingFuckerMan::Instance()->SetBufferValue( FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart/*+randint(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen)*/, + // /* (float)((*(&ppc_state.r0)+value)-INT_MAX)/INT_MAX * */coinflip()?1.0:-1.0 ); + // FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastreg= *((&ppc_state.r0)+value); + // } + // } + // if(FuckingFuckerMan::Instance()->IsOSCOn()) [[OscMan sharedMan] sendDiracWithPan:analysis->cursor]; - + } else { return -2; } -return -1; + return -1; } int i386_64AnalyzeState(task_t& port, void* thread_state, void* float_state, void* priv, int & printtimer) { - struct attach_data& attach = *((struct attach_data*)priv) ; + struct attach_data& attach = *((struct attach_data*)priv) ; disassemble_info_i386* info = (disassemble_info_i386* ) attach.priv; - + x86_thread_state64_t& threadState = *((x86_thread_state64_t*) thread_state); x86_float_state64_t& floatState = *((x86_float_state64_t*) float_state); - + printf("attempt attach 64\n"); + //it appears there are several really boring FUCKINGEIP/pc values that are constant for all programs - skip these if(threadState.FUCKINGRIP == 0x90009CD7 || threadState.FUCKINGRIP == 0x900248C7 || threadState.FUCKINGRIP == 0x90037B57 - || threadState.FUCKINGRIP == 0x90047DD7 || threadState.FUCKINGRIP == 0x900248C7) + || threadState.FUCKINGRIP == 0x90047DD7 || threadState.FUCKINGRIP == 0x900248C7) return -1; //reset the print cursor @@ -844,62 +862,65 @@ opcode+=dis_priv->the_buffer[i]; opcode= opcode << 8; } - - + + //jae + if(opcode == 0x730E00) { + return -1; + } - opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); + opcode_analysis* analysis = FuckingFuckerMan::Instance()->GetOpcodeAnalysis(); if(printtimer<0) { printtimer=kPrintTimerFireMicros; FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat:@"pc: 0x%qX opcode:%qX byte:%.2X inst:(%s)\n",threadState.FUCKINGRIP,opcode,(int)info->opcodebyte, info->desc]); -//start backtrace - doesnt work for intel mac core2duo -// //QSymbols testSymbols; -// QBTFrame * frames; -// size_t frameToAllocate; -// size_t frameCount; -// frameToAllocate = 15; -// //testSymbols.didSuspend = true; -// -// -//frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); -// -// -// int btres = QBacktraceMachThreadState( -// port, -// /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; -// &threadState, -// sizeof(i386_thread_state_t), -// CPU_TYPE_X86,// QMOGetLocalCPUType(), -// NULL,// &testSymbols,//symRef, -// 0, -// 0, -// frames, -// frameToAllocate, -// &frameCount -// ); -// char* space; -// space = (char*) malloc(frameToAllocate+1); -// //fill it with holes -// memset(space,' ',frameToAllocate); -// //terminate it -// space[frameToAllocate]=0; -// if(btres==0) -// { -// for(int i=0;i<mymin(frameCount,frameToAllocate);i++) -// { -// //adds indentation by using pointer arithmathic and the spaces string -// FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: -// @"%spc:%qX fp:%qX %s %s\n", -// space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)",frames[i].library?frames[i].library:"" ]); -// -// } -// } -// free(space); -// QBacktraceDisposeSymbols(frames,frameToAllocate); -//// QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); -// free(frames); -////end backtrace - + //start backtrace - doesnt work for intel mac core2duo + // //QSymbols testSymbols; + // QBTFrame * frames; + // size_t frameToAllocate; + // size_t frameCount; + // frameToAllocate = 15; + // //testSymbols.didSuspend = true; + // + // + //frames = (QBTFrame *) calloc(frameToAllocate, sizeof(QBTFrame)); + // + // + // int btres = QBacktraceMachThreadState( + // port, + // /*flavor = */x86_THREAD_STATE32, //x86_THREAD_STATE32; + // &threadState, + // sizeof(i386_thread_state_t), + // CPU_TYPE_X86,// QMOGetLocalCPUType(), + // NULL,// &testSymbols,//symRef, + // 0, + // 0, + // frames, + // frameToAllocate, + // &frameCount + // ); + // char* space; + // space = (char*) malloc(frameToAllocate+1); + // //fill it with holes + // memset(space,' ',frameToAllocate); + // //terminate it + // space[frameToAllocate]=0; + // if(btres==0) + // { + // for(int i=0;i<mymin(frameCount,frameToAllocate);i++) + // { + // //adds indentation by using pointer arithmathic and the spaces string + // FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: + // @"%spc:%qX fp:%qX %s %s\n", + // space+frameToAllocate-i,frames[i].pc,frames[i].fp,frames[i].symbol?frames[i].symbol:"(no symbol)",frames[i].library?frames[i].library:"" ]); + // + // } + // } + // free(space); + // QBacktraceDisposeSymbols(frames,frameToAllocate); + //// QBacktraceDisposeSymbols(frames,mymin(frameCount,frameToAllocate)); + // free(frames); + ////end backtrace + } //turn it into a sample and insert it into the sound manager. //the op alone ranges from 0-0x3f (0-191) @@ -915,46 +936,46 @@ analysis->cursor = (float) (threadState.FUCKINGRIP-analysis->minpc)/analysis->maxpc; analysis->phase = ((float)info->opcodebyte/256.0)*M_PI; analysis->freq = 0.1+exp2cursor((float)info->opcodebyte/256.0)*5.0;//allow aliasing. - analysis->buflen =((float)info->opcodebyte/256.0)*kFFManAudioBufferSize*0.5+512; - //analysis->bufstart = randfloat(mymin(1.0,analysis->cursor+0.3))*(kFFManAudioBufferSize-analysis->buflen); - - FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart = randint(kFFManAudioBufferSize-FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen); - analysis->mode = info->opcodebyte%4;//4 modes - - //for(int j=0;j<info.numoperands;j++) -// { -// struct powerpc_operand *operand; -// long value; //holds the register number or the absolute value if one is specified -// operand = &info.operands[j]; -// value = operand_value_powerpc (operand, instruction, 1); -// if ((operand->flags & PPC_OPERAND_GPR) != 0 -// || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) -// { -// //convert the unsigned int at the register to a float from -1.0 to 1.0 -// FuckingFuckerMan::Instance()->SetBufferValue( FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart/*+randint(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen)*/, -// /* (float)((*(&ppc_state.r0)+value)-INT_MAX)/INT_MAX * */coinflip()?1.0:-1.0 ); -// FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastreg= *((&ppc_state.r0)+value); -// } -// } -// + analysis->buflen =((float)info->opcodebyte/256.0)*kFFManAudioBufferSize*0.5+512; + //analysis->bufstart = randfloat(mymin(1.0,analysis->cursor+0.3))*(kFFManAudioBufferSize-analysis->buflen); + + FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart = randint(kFFManAudioBufferSize-FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen); + analysis->mode = info->opcodebyte%4;//4 modes + + //for(int j=0;j<info.numoperands;j++) + // { + // struct powerpc_operand *operand; + // long value; //holds the register number or the absolute value if one is specified + // operand = &info.operands[j]; + // value = operand_value_powerpc (operand, instruction, 1); + // if ((operand->flags & PPC_OPERAND_GPR) != 0 + // || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) + // { + // //convert the unsigned int at the register to a float from -1.0 to 1.0 + // FuckingFuckerMan::Instance()->SetBufferValue( FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->bufstart/*+randint(FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->buflen)*/, + // /* (float)((*(&ppc_state.r0)+value)-INT_MAX)/INT_MAX * */coinflip()?1.0:-1.0 ); + // FuckingFuckerMan::Instance()->GetOpcodeAnalysis()->lastreg= *((&ppc_state.r0)+value); + // } + // } + // if(FuckingFuckerMan::Instance()->IsOSCOn()) [[OscMan sharedMan] sendDiracWithPan:analysis->cursor]; - + } else { return -2; } -return -1; + return -1; } //attached thread. - long +long operand_value_powerpc (const struct powerpc_operand *operand, - unsigned long insn, ppc_cpu_t dialect); + unsigned long insn, ppc_cpu_t dialect); void *attachProcessHelper(void* arg) { int i = 0; @@ -971,34 +992,34 @@ kern_return_t errCode; errCode=task_for_pid(mach_task_self(), pid, &port); //TODO:are we leaking this? - + //Fetch more info about the process thread_act_port_array_t thread_list; mach_msg_type_number_t thread_count; errCode=task_threads(port, &thread_list, &thread_count); - + //print the info. - + //nothing to do if no threads if(!thread_list || thread_count <= 0) { FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"PID: %i attach failed\n",pid]); - //deallocate the memory from task_threads + //deallocate the memory from task_threads err = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_array_t)); assert(err == KERN_SUCCESS); - - return NULL; + + return NULL; } else { FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"PID: %i attaching with %i threads\n",pid,thread_count]); (*attach->pf_set_taskport)(attach->priv, port); } - //deallocate the memory from task_threads + //deallocate the memory from task_threads err = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_array_t)); assert(err == KERN_SUCCESS); - + //suspend the process to get some stuff. //main loop: keep processing until we get a detach message. @@ -1011,17 +1032,17 @@ { float speedControl; speedControl = FuckingFuckerMan::Instance()->GetSpeedControl(); - + //check if we should detach. if(attach->token < FuckingFuckerMan::Instance()->GetCurrentAttachToken()) - break; - + break; + err=task_suspend(port); if(err != KERN_SUCCESS) { FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"PID: %i has quit.\n",pid]); - (*attach->pf_cleanup_attach_data)(attach); - delete attach; + (*attach->pf_cleanup_attach_data)(attach); + delete attach; return NULL; } task_threads(port, &thread_list, &thread_count); @@ -1034,21 +1055,21 @@ err = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_array_t)); assert(err == KERN_SUCCESS); - (*attach->pf_cleanup_attach_data)(attach); - delete attach; + (*attach->pf_cleanup_attach_data)(attach); + delete attach; return NULL; } if(thread_count != lastnumthreads) { - lastnumthreads=thread_count; - FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"PID %i Num Threads Changed! now: %i\n",pid,thread_count]); + lastnumthreads=thread_count; + FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"PID %i Num Threads Changed! now: %i\n",pid,thread_count]); } //decrement the timer so that it can fire. printtimer -=kOpDelayMicros; for(i=0;i<thread_count;i++) { - //fetch thread state using function pointers that point to functions for given cpu + //fetch thread state using function pointers that point to functions for given cpu (*attach->pf_get_thread_state)(thread_list[i], attach->thread_state, &sc ); (*attach->pf_get_float_state)(thread_list[i], attach->float_state, &sc ); err = (*attach->pf_analyze_state)(port, attach->thread_state, attach->float_state, attach, printtimer); @@ -1057,18 +1078,18 @@ if(err==-2) { FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: - @"PID:%i minor error - continuing\n",pid]); - + @"PID:%i minor error - continuing\n",pid]); + } else { FuckingFuckerMan::Instance()->AppendToOutput( [NSString stringWithFormat: - @"PID:%i error: %i, sizein: %i, DETACHING\n",pid, err, sc]); - - task_resume(port); - (*attach->pf_cleanup_attach_data)(attach); - delete attach; - return 0; + @"PID:%i error: %i, sizein: %i, DETACHING\n",pid, err, sc]); + + task_resume(port); + (*attach->pf_cleanup_attach_data)(attach); + delete attach; + return 0; } } //deallocate memory from thread_get_state - this crashes us here and seems to be unecessary @@ -1088,12 +1109,12 @@ //free objective c memory that has been released [pool release]; pool = [[NSAutoreleasePool alloc] init]; - + //save this data to the output queue string (lock/release) usleep(kOpDelayMicros*speedControl); } //apply suspend for a certain amount of time if we have speed controll on. -// mach_port_deallocate(my_task, me); + // mach_port_deallocate(my_task, me); (*attach->pf_cleanup_attach_data)(attach); delete attach; FuckingFuckerMan::Instance()->AppendToOutput([NSString stringWithFormat:@"PID %i detaching normally\n",pid]); Modified: FuckingFucker/OscMan.mm =================================================================== --- FuckingFucker/OscMan.mm 2010-07-25 19:12:39 UTC (rev 232) +++ FuckingFucker/OscMan.mm 2010-07-27 21:38:51 UTC (rev 233) @@ -116,7 +116,7 @@ // convStr=[[str substringToIndex:255] cStringUsingEncoding:[NSString defaultCStringEncoding]]; //else //convStr= [str cStringUsingEncoding:[NSString defaultCStringEncoding]]; - lo_send(t, "/s_new", "siiisf", "dirac", nodeID++, 1, 0, "pan", 1.0);// pan);//, loc, num+randSenderNum); + lo_send(t, "/s_new", "siiisf", "dirac", nodeID++, 1, 0, "pan", pan);//, loc, num+randSenderNum); lo_address_free(t); if(nodeID>10000) nodeID=1000; Modified: FuckingFucker/boincbacktrace/QBacktrace.c =================================================================== --- FuckingFucker/boincbacktrace/QBacktrace.c 2010-07-25 19:12:39 UTC (rev 232) +++ FuckingFucker/boincbacktrace/QBacktrace.c 2010-07-27 21:38:51 UTC (rev 233) @@ -919,12 +919,15 @@ } else { context->symRef = symRef; } + if (err == 0) { qmoImage = QSymGetExecutableImage(context->symRef); if (qmoImage == NULL) { err = EINVAL; } - } + }else + printf("initcontext err:%d\n",err); + if (err == 0) { context->swapBytes = QMOImageIsByteSwapped(qmoImage); @@ -943,7 +946,10 @@ err = QSymGetAddressForSymbol(context->symRef, "/usr/lib/libSystem.B.dylib", "__sigtramp", &symInfo); if (err == 0) { context->sigTrampLowerBound = symInfo.symbolValue; - } + }else + printf("MachInitContext QSymGetAddressForSymbol err:%d\n",err); + + if (err == 0) { err = QSymGetNextSymbol(context->symRef, &symInfo, &nextSymInfo); if (err == 0) { @@ -955,7 +961,8 @@ err = 0; } } - } + }else + printf("initcontext2 err:%d\n",err); assert( (err != 0) || QBTContextIsValid(context) ); @@ -2331,7 +2338,8 @@ context.threadStateFlavor = stateFlavor; context.threadState = state; context.threadStateSize = stateSize; - } + }else + printf("error1: %d\n", err); // Do the backt... [truncated message content] |
From: <mc...@us...> - 2010-07-25 19:12:45
|
Revision: 232 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=232&view=rev Author: mchinen Date: 2010-07-25 19:12:39 +0000 (Sun, 25 Jul 2010) Log Message: ----------- add current position playback time drawing Modified Paths: -------------- NoiseMP3/PlayerView.m Modified: NoiseMP3/PlayerView.m =================================================================== --- NoiseMP3/PlayerView.m 2010-07-25 18:55:41 UTC (rev 231) +++ NoiseMP3/PlayerView.m 2010-07-25 19:12:39 UTC (rev 232) @@ -361,20 +361,43 @@ #define kDurationTextXOffset -6 //number of y pixels after bottom side for duration text #define kDurationTextYOffset 0 +#define kCurrentPosTextYOffset -40 -(void) drawDuration { - //make it white. - unsigned char* bitmap = [renderBitmap bitmapData]; + //erase + //also draw a notehead on the end of the line. + float textX = [renderBitmap pixelsWide]-kPlayBarMargin +kDurationTextXOffset; + float textY = [renderBitmap pixelsHigh]*kPlayBarYRatio+kPlayBarHeight +kDurationTextYOffset + kCurrentPosTextYOffset; + float textY2 = [renderBitmap pixelsHigh]*kPlayBarYRatio+kPlayBarHeight; + textX=textX / [renderBitmap pixelsWide]; + textY=textY / [renderBitmap pixelsHigh]; + textY2=textY2 / [renderBitmap pixelsHigh]; + textX = 2.0*(textX-0.5); + textY = 2.0*(textY-0.5); + textY2 = 2.0*(textY-0.5); + glBegin(GL_POLYGON); + glColor4f(1.0,1.0,1.0,0.1); + glVertex2f(textX, textY); + glVertex2f(1.0, textY); + glVertex2f(1.0, textY2); + glVertex2f(textX, textY2); + glEnd(); + + + + + int duration = [controller getSongDuration]; - if(duration!=0 && (duration!=lastDuration || redrawDuration)) - { + int curpos = duration * [controller getPlaybackCursor]; +// if(duration !=0 && (duration!=lastDuration || redrawDuration)) + // { redrawDuration = NO; lastDuration=duration; //draw duration as text - float textX = [renderBitmap pixelsWide]-kPlayBarMargin +kDurationTextXOffset; - float textY = [renderBitmap pixelsHigh]*kPlayBarYRatio+kPlayBarHeight +kDurationTextYOffset; + textX = [renderBitmap pixelsWide]-kPlayBarMargin +kDurationTextXOffset; + textY = [renderBitmap pixelsHigh]*kPlayBarYRatio+kPlayBarHeight +kDurationTextYOffset; textX=textX / [renderBitmap pixelsWide]; textY=textY / [renderBitmap pixelsHigh]; textX = 2.0*(textX-0.5); @@ -386,7 +409,7 @@ // [NSFont systemFontOfSize:10],NSFontAttributeName,nil]]; StringTexture* helpString=[[StringTexture alloc] - initWithString: [NSString stringWithFormat:@"%i'%i\"",duration/60,duration%60] + initWithString: [NSString stringWithFormat:@"%i'%02i\"",duration/60,duration%60] withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSColor blackColor],NSForegroundColorAttributeName, [NSFont systemFontOfSize:10],NSFontAttributeName,nil] withTextColor:[NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha:1.0f] @@ -398,7 +421,28 @@ [self drawText:helpString atGLX:textX atGLY:textY atEnd:NO]; [helpString release]; - } + + //----- current time position + textY = [renderBitmap pixelsHigh]*kPlayBarYRatio+kPlayBarHeight +kDurationTextYOffset + kCurrentPosTextYOffset; + textY=textY / [renderBitmap pixelsHigh]; + textY = 2.0*(textY-0.5); + + helpString=[[StringTexture alloc] + initWithString: [NSString stringWithFormat:@"%i'%02i\"",curpos/60,curpos%60] + withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSColor blackColor],NSForegroundColorAttributeName, + [NSFont systemFontOfSize:10],NSFontAttributeName,nil] + withTextColor:[NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha:1.0f] + withBoxColor:[NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha:0.0f] + withBorderColor:[NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha:0.0f]]; + + //this lets the text draw. + glColor4f(0.0,0.0,0.0,1.0); + + [self drawText:helpString atGLX:textX atGLY:textY atEnd:NO]; + [helpString release]; + + +// } } - (void) eraseActivityText:(float)textY height:(float)textHeight This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-25 18:55:48
|
Revision: 231 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=231&view=rev Author: mchinen Date: 2010-07-25 18:55:41 +0000 (Sun, 25 Jul 2010) Log Message: ----------- temporary chirp synth fixups Modified Paths: -------------- NoiseMP3/ChirpSynth.cpp NoiseMP3/ChirpSynth.h NoiseMP3/PlayerModel.mm Modified: NoiseMP3/ChirpSynth.cpp =================================================================== --- NoiseMP3/ChirpSynth.cpp 2010-07-25 18:36:03 UTC (rev 230) +++ NoiseMP3/ChirpSynth.cpp 2010-07-25 18:55:41 UTC (rev 231) @@ -102,9 +102,9 @@ nb_bw = 0.0; nb_phase = 0.0; nb_amp = 1.0; - - quantSize = randfloatexp2(20)+4; + quantSize = 1;///randfloatexp2(40)+ initedForRealTime = false; + octavesDown=0; } void ChirpSynth::FillData(int framesPerBuffer, float** outBufs, float amp, PlayerModel* model, MP3Decoder* decoder) @@ -146,8 +146,11 @@ outValueR += ((float**)outBufs)[1][outCursor]; - outValueL = (1.0-m_volume)*((int)(quantSize * outValueL)/(float)quantSize) + m_volume*(((float**)outBufs)[0][outCursor] + nbSamp); - outValueR = (1.0-m_volume)*((int)(quantSize * outValueR)/(float)quantSize) + m_volume*(((float**)outBufs)[1][outCursor] + nbSamp); +// outValueL = dbtoamp (quantSize * (amptodb(outValueL)/quantSize)); +// outValueR = dbtoamp (quantSize * (amptodb(outValueR)/quantSize)); + + outValueL = (1.0-m_volume)*outValueL + m_volume*(((float**)outBufs)[0][outCursor] + nbSamp); + outValueR = (1.0-m_volume)*outValueR + m_volume*(((float**)outBufs)[1][outCursor] + nbSamp); ((float**)outBufs)[0][outCursor] = outValueL;// * (1.0-pan); @@ -235,6 +238,8 @@ // // output = sin(phase)*env; +// if(octavesDown) +// interpFreq/= 1 << octavesDown; nb_freq = interpFreq; nb_bw = (1.0-m_volume)/7; NoiseBandFillFrame(&output, 1, 1.0); Modified: NoiseMP3/ChirpSynth.h =================================================================== --- NoiseMP3/ChirpSynth.h 2010-07-25 18:36:03 UTC (rev 230) +++ NoiseMP3/ChirpSynth.h 2010-07-25 18:55:41 UTC (rev 231) @@ -19,6 +19,7 @@ ChirpSynth(UserActivity* act); virtual ~ChirpSynth(){} virtual void FillData(int framesPerBuffer, float** outBufs, float amp, PlayerModel* model, MP3Decoder* decoder); + void SetOctavesDown(int octaves){octavesDown = octaves;} protected: void NoiseBandFillFrame(float* buf, int length, float vol); virtual void InitNewChar(char ch); @@ -47,6 +48,7 @@ int samplesTillNextTarget; bool initedForRealTime; + int octavesDown; //quant dist. int quantSize; }; Modified: NoiseMP3/PlayerModel.mm =================================================================== --- NoiseMP3/PlayerModel.mm 2010-07-25 18:36:03 UTC (rev 230) +++ NoiseMP3/PlayerModel.mm 2010-07-25 18:55:41 UTC (rev 231) @@ -344,12 +344,15 @@ #define kNoiseCutoffPages 20 pageRatio = (pageNum+1) /(float)(topPage + 1); // pageRatio = pageRatio < 0.2 ? 0.2 : pageRatio; + chirpVol = (pageNum-kNoiseCutoffPages + 1)/(float)(topPage - kNoiseCutoffPages +1); if(chirpVol<0) chirpVol = 0; + synth = new ChirpSynth(act); synth->SetVolume(chirpVol); +// ((ChirpSynth*)synth)->SetOctavesDown(topPage-pageNum); FuckingAudioIO::Instance()->AddSynth(synth); - printf("pageratio %f\n", pageRatio); + printf("pageratio %f, chirpvol %f\n", pageRatio,chirpVol); if(pageNum >= topPage - kEffectCuttoffPages) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-25 18:36:09
|
Revision: 230 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=230&view=rev Author: mchinen Date: 2010-07-25 18:36:03 +0000 (Sun, 25 Jul 2010) Log Message: ----------- add noise to chirp synth Modified Paths: -------------- NoiseMP3/ChirpSynth.cpp NoiseMP3/ChirpSynth.h NoiseMP3/DownsampleSynth.cpp NoiseMP3/DownsampleSynth.h NoiseMP3/FuckingAudioIO.cpp NoiseMP3/GUINoiseSynth.cpp NoiseMP3/PlayerModel.mm Modified: NoiseMP3/ChirpSynth.cpp =================================================================== --- NoiseMP3/ChirpSynth.cpp 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/ChirpSynth.cpp 2010-07-25 18:36:03 UTC (rev 230) @@ -15,11 +15,96 @@ #define SR 44100 #define PI 3.1415926 + + + + +//generate a block the size of the buffer. +void ChirpSynth::NoiseBandFillFrame(float* buf, int length, float vol) +{ + if(!initedForRealTime) + { + + laston = false; + lastfreq = nb_freq; + lastamp = 0.0; + lastbw = nb_bw; + instfreq = nb_freq; + targetfreq = nb_freq; + + phase = nb_phase; + samplesTillNextTarget=0; + initedForRealTime = true; + } + + + double phaseAdd; + float amp = lastamp; + + float freq = lastfreq; + float bw =lastbw; + //for quick ref + + float curamp; + float curfreq; + float curbw; + + curamp = nb_amp; + curfreq = nb_freq; + curbw = nb_bw; + + + for(int j = 0 ; j<length ; j++ ) + { + + bw = curbw;//curpg->Interpolate(3,lastbw,curbw,length==0?1.0:(float)j/(float)length,bwFormat); + freq = curfreq;//curpg->Interpolate(1,lastfreq,curfreq,length==0?1.0:(float)j/(float)length,freqFormat); + amp = curamp;//curpg->Interpolate(0,lastamp,on?curamp:0.0,length==0?1.0:(float)j/(float)length,ampFormat); + + + //see if we need a new target + if(samplesTillNextTarget <0 || targetfreq > freq*(1.0+bw) || targetfreq< freq*(1.0-bw)) + { + targetfreq = randfloat(freq*bw*2.0)+freq*(1.0-bw); //assumes bw <1.0 + samplesTillNextTarget = randint(44100/mymax(2.0,freq))+1.0; + }else + { + samplesTillNextTarget--; + } + + instfreq = instfreq + (targetfreq-instfreq)/mymax(1.0,samplesTillNextTarget); + + phaseAdd = instfreq*2.0*3.141592/44100.0; + //phaseAdd += phaseAdd* (randfloat(bw*2)-bw); + + phase += phaseAdd; + while(phase>2.0*3.141592) + phase-=2.0*3.141592; + + buf[j]+=amp*sin(phase) *vol; + // buf[j*2+1]+=amp*sin(phase) * vol; + } + + lastamp = amp; + lastfreq = freq; + lastbw = bw; +} + + ChirpSynth::ChirpSynth(UserActivity* act) :PulseSynth(act) { //pulsesynth sets up the buffers. charcount = -1; + + //noiseband + nb_freq =1000; + nb_bw = 0.0; + nb_phase = 0.0; + nb_amp = 1.0; + + quantSize = randfloatexp2(20)+4; + initedForRealTime = false; } void ChirpSynth::FillData(int framesPerBuffer, float** outBufs, float amp, PlayerModel* model, MP3Decoder* decoder) @@ -28,7 +113,9 @@ { int outCursor =0; int charFrames; - float outValue; + float outValueL; + float outValueR; + float nbSamp; //process characters until we run out of them or audio samples to output for this frame. while(outCursor<framesPerBuffer && charBuffer.size()) @@ -48,12 +135,24 @@ charFrames+=outCursor; for(;outCursor<charFrames;outCursor++) { - outValue=ComputeSample() * amp * m_volume; +#define kChirpSynthGain 0.3 + nbSamp=ComputeSample() * kChirpSynthGain; + outValueL = nbSamp;//*m_volume;// + nbSamp * (1.0-m_volume) * ((float**)outBufs)[0][outCursor]; +// outValueL *= amp; * (1.0 - (1.0-m_volume)/2); + outValueR = nbSamp;//*m_volume;// + nbSamp * (1.0-m_volume) * ((float**)outBufs)[1][outCursor]; +// outValueR *= amp * (1.0 - (1.0-m_volume)/2); - ((float**)outBufs)[0][outCursor]+= outValue * (1.0-pan) * m_volume; - ((float**)outBufs)[1][outCursor]+= outValue * pan * m_volume; + outValueL += ((float**)outBufs)[0][outCursor]; + outValueR += ((float**)outBufs)[1][outCursor]; + outValueL = (1.0-m_volume)*((int)(quantSize * outValueL)/(float)quantSize) + m_volume*(((float**)outBufs)[0][outCursor] + nbSamp); + outValueR = (1.0-m_volume)*((int)(quantSize * outValueR)/(float)quantSize) + m_volume*(((float**)outBufs)[1][outCursor] + nbSamp); + + + ((float**)outBufs)[0][outCursor] = outValueL;// * (1.0-pan); + ((float**)outBufs)[1][outCursor] = outValueR;// * pan; + } } @@ -96,6 +195,7 @@ pulseRestSamps = pulseDuration* ((ch*charcount)%3?0.5:0.2); pulseSustainSamps = pulseDuration - pulseAtkSamps - pulseReleaseSamps - pulseRestSamps; +initedForRealTime=false; } float ChirpSynth::ComputeSample() @@ -103,11 +203,7 @@ float env; #define kChirpSynthAttack 0.01*SR #define kChirpSynthRelease 0.1*SR -#define kChirpSynthEnd kChirpSynthAttack+kChirpSynthRelease - -#define kPulseWidth 0.3 - - +#define kChirpSynthEnd kChirpSynthAttack+kChirpSynthRelease env = pulseCursor<pulseAtkSamps?((float)pulseCursor/pulseAtkSamps): //attack-move from 0 to 1 pulseCursor<(pulseAtkSamps+pulseSustainSamps)?1.0: pulseCursor<(pulseDuration-pulseRestSamps)?(1.0 - ((float)(pulseCursor-(pulseAtkSamps+pulseSustainSamps)))/pulseReleaseSamps): //release - 1.0 to 0 @@ -116,9 +212,6 @@ float cursorRatio = (float)pulseCursor/(pulseDuration-pulseRestSamps); float interpFreq = cursorRatio*freq+(1.0-cursorRatio)*freq2; - -// interpFreq = interpFreq; -// interpFreq = (((int)mymin(interpFreq,4000)/220)+1)*220; //convert to midi interpFreq=mymax(interpFreq,1000); interpFreq =(int)( 69 + 12*log(interpFreq/440)/log(2)); @@ -126,30 +219,63 @@ interpFreq = ((int)(interpFreq/2))*2; //back to freq interpFreq = 440 * ((interpFreq-69)/12)*((interpFreq-69)/12); - - - phase += interpFreq*2.0*PI/SR; - - while(phase > 2.0*PI) - phase-=2.0*PI; - while(phase < -2.0*PI) - phase+=2.0*PI; - - float output; - output = sin(phase)*env; + + + float output=0; + + if(interpFreq>10000) + printf("testfreq %f", interpFreq); + +// phase += interpFreq*2.0*PI/SR; +// +// while(phase > 2.0*PI) +// phase-=2.0*PI; +// while(phase < -2.0*PI) +// phase+=2.0*PI; +// +// output = sin(phase)*env; + + nb_freq = interpFreq; + nb_bw = (1.0-m_volume)/7; + NoiseBandFillFrame(&output, 1, 1.0); + output*=env; - return output; - - //FM - //return ((sin(phase+sin(phase2)*2.0))*2.3); - //return ((sin(phase+sin(phase2)*2.0))*2.3)+((sin(phase2+sin(phase)*3.0))*0.2); - //return (sin(phase2+sin(phase)*2.0))*sin(phase*2.3); - - //return sin(phase); - //return sin(phase)*sin(phase*100.2)-cos(phase*0.5); - //return sin(phase)*cos(phase*100.2); - //return sin(phase)*cos(phase*789.2)*sin(phase*300.3); - //return sin(phase)*cos(phase*20000.2)*sin(phase*0.3); - + return output; } - +// +//float ChirpSynth::ComputeSample() +//{ +// float env; +//#define kChirpSynthAttack 0.01*SR +//#define kChirpSynthRelease 0.1*SR +//#define kChirpSynthEnd kChirpSynthAttack+kChirpSynthRelease +// env = pulseCursor<pulseAtkSamps?((float)pulseCursor/pulseAtkSamps): //attack-move from 0 to 1 +// pulseCursor<(pulseAtkSamps+pulseSustainSamps)?1.0: +// pulseCursor<(pulseDuration-pulseRestSamps)?(1.0 - ((float)(pulseCursor-(pulseAtkSamps+pulseSustainSamps)))/pulseReleaseSamps): //release - 1.0 to 0 +// 0.0;//after the release is silence +// pulseCursor++; +// +// float cursorRatio = (float)pulseCursor/(pulseDuration-pulseRestSamps); +// float interpFreq = cursorRatio*freq+(1.0-cursorRatio)*freq2; +// //convert to midi +// interpFreq=mymax(interpFreq,1000); +// interpFreq =(int)( 69 + 12*log(interpFreq/440)/log(2)); +// //crunch it down. +// interpFreq = ((int)(interpFreq/2))*2; +// //back to freq +// interpFreq = 440 * ((interpFreq-69)/12)*((interpFreq-69)/12); +// +// +// phase += interpFreq*2.0*PI/SR; +// +// while(phase > 2.0*PI) +// phase-=2.0*PI; +// while(phase < -2.0*PI) +// phase+=2.0*PI; +// +// float output; +// output = sin(phase)*env; +// +// return output; +//} +// Modified: NoiseMP3/ChirpSynth.h =================================================================== --- NoiseMP3/ChirpSynth.h 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/ChirpSynth.h 2010-07-25 18:36:03 UTC (rev 230) @@ -20,6 +20,7 @@ virtual ~ChirpSynth(){} virtual void FillData(int framesPerBuffer, float** outBufs, float amp, PlayerModel* model, MP3Decoder* decoder); protected: + void NoiseBandFillFrame(float* buf, int length, float vol); virtual void InitNewChar(char ch); float ComputeSample(); int charcount; @@ -27,5 +28,26 @@ int pulseReleaseSamps ; int pulseRestSamps ; int pulseSustainSamps ; + + //noiseband +//actual desired params +float nb_freq; +float nb_bw; +float nb_phase; +float nb_amp; + + //for real time state keeping +bool laston; +float lastfreq; +float lastamp; +float lastbw; +float instfreq; +//float phase; +float targetfreq; +int samplesTillNextTarget; +bool initedForRealTime; + + //quant dist. + int quantSize; }; #endif// __FUCKING_PULSESYNTH__ Modified: NoiseMP3/DownsampleSynth.cpp =================================================================== --- NoiseMP3/DownsampleSynth.cpp 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/DownsampleSynth.cpp 2010-07-25 18:36:03 UTC (rev 230) @@ -15,13 +15,13 @@ #define SR 44100 #define PI 3.1415926 -#define kGranLifetime 44100*6 +#define kGranLifetime 44100*3 DownsampleSynth::DownsampleSynth(UserActivity* act) :Synth(act) { float dice = [act getCursor]; //random lifetime with exponential dist so we have equal amount of 'short' and 'long' instead of mostly medium durs. - origlifetime = lifetime = randfloatexp2(1.0)*kGranLifetime +1; + origlifetime = lifetime = randfloat(1.0)*kGranLifetime +44100/2; discreteRatio = ((int)(dice*411)%30); dsAmtl = ((int)(dice*363) %6) +1; @@ -98,10 +98,11 @@ float filter_state2 =0.0; /* input_buf can be equal to output_buf */ -static void downsample_interleaved( float *input_buf, float *output_buf,int downsampleRatio, int output_count, int num_chans, int targetChan, float volume) { +void DownsampleSynth::downsample_interleaved( float *input_buf, float *output_buf,int downsampleRatio, int output_count, int num_chans, int targetChan, float volume) { int input_idx, input_end, output_idx; float next_sam; float* filter_state; + int lifetime_tmp = lifetime; for(int i=0;i<num_chans;i++){ filter_state=targetChan?&filter_state2:&filter_state1; @@ -112,11 +113,17 @@ next_sam = input_buf[input_idx]; input_idx+=num_chans * downsampleRatio; - float dcursor; + float dcursor, fadedVolume; for(int j=0;j<downsampleRatio;j++) { + //get the envelope post fade + fadedVolume = lifetime_tmp < origlifetime/2?(((float)lifetime_tmp)/(origlifetime/2)):(2.0*(0.5 - ((float)lifetime_tmp)/(origlifetime))); //the envelope fadings make the *2 necessary + fadedVolume *= volume; + lifetime_tmp--; + + dcursor = ((float)(j+1)/downsampleRatio); - output_buf[ output_idx] = dcursor * next_sam + (1.0-dcursor)* *filter_state * volume; + output_buf[ output_idx] = (dcursor * next_sam + (1.0-dcursor)* *filter_state) * fadedVolume + (output_buf[ output_idx] * (1.0-fadedVolume)); output_idx+=num_chans; } Modified: NoiseMP3/DownsampleSynth.h =================================================================== --- NoiseMP3/DownsampleSynth.h 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/DownsampleSynth.h 2010-07-25 18:36:03 UTC (rev 230) @@ -32,6 +32,8 @@ virtual bool IsFinished(); virtual void FillData(int framesPerBuffer, float** outBufs, float amp, PlayerModel* model, MP3Decoder* decoder); protected: + + void downsample_interleaved( float *input_buf, float *output_buf,int downsampleRatio, int output_count, int num_chans, int targetChan, float volume); int dsAmtl; int dsAmtr; int discreteRatio; Modified: NoiseMP3/FuckingAudioIO.cpp =================================================================== --- NoiseMP3/FuckingAudioIO.cpp 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/FuckingAudioIO.cpp 2010-07-25 18:36:03 UTC (rev 230) @@ -50,7 +50,7 @@ //this is a non-interleaved fill pthread_mutex_lock(priv->decoderLock); - priv->decoder->FillData(framesPerBuffer,(float**)outputBuffer, priv->amp); + priv->decoder->FillData(framesPerBuffer,(float**)outputBuffer, 1.0);//priv->amp); pthread_mutex_unlock(priv->decoderLock); std::vector<Synth*>& synths = FuckingAudioIO::Instance()->GetSynths(); @@ -62,7 +62,11 @@ synths[i]->FillData(framesPerBuffer,(float**)outputBuffer,priv->amp,priv->model,priv->decoder); pthread_mutex_unlock(priv->decoderLock); } - + //decrease by the amplitude + for(int i=0; i< framesPerBuffer; i++) { + ((float**)outputBuffer)[0][i] *= priv->amp; + ((float**)outputBuffer)[1][i] *= priv->amp; + } //make a second pass and delete synths that have finished. for(int i=0;i<synths.size();i++) { Modified: NoiseMP3/GUINoiseSynth.cpp =================================================================== --- NoiseMP3/GUINoiseSynth.cpp 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/GUINoiseSynth.cpp 2010-07-25 18:36:03 UTC (rev 230) @@ -61,7 +61,7 @@ else if(f > 1.0 || f<-1.0) f = (f/std::numeric_limits<float>::max()); - ((float**)outBufs)[z][i]+= f * amp*fadedVolume; + ((float**)outBufs)[z][i]+= f *fadedVolume; // memcpy(((float*)outputBuffer)+framesPerBuffer*z,noisearray+randint(framesPerBuffer*(noisefactor)),framesPerBuffer*sizeof(float)); } } Modified: NoiseMP3/PlayerModel.mm =================================================================== --- NoiseMP3/PlayerModel.mm 2010-07-25 14:38:28 UTC (rev 229) +++ NoiseMP3/PlayerModel.mm 2010-07-25 18:36:03 UTC (rev 230) @@ -335,21 +335,22 @@ //make volume softer based on layer number float pageRatio; - float effectVol; + float chirpVol = 1.0; + float effectVol = 1.0; int topPage = [[self getSongActivityList] getSelectedPage]; int pageNum = [[act getPage] getPageNumber]; - +#define kEffectCuttoffPages 3 +#define kNoiseCutoffPages 20 pageRatio = (pageNum+1) /(float)(topPage + 1); - pageRatio = pageRatio < 0.2 ? 0.2 : pageRatio; - - +// pageRatio = pageRatio < 0.2 ? 0.2 : pageRatio; + chirpVol = (pageNum-kNoiseCutoffPages + 1)/(float)(topPage - kNoiseCutoffPages +1); + if(chirpVol<0) chirpVol = 0; synth = new ChirpSynth(act); - synth->SetVolume(pageRatio); + synth->SetVolume(chirpVol); FuckingAudioIO::Instance()->AddSynth(synth); printf("pageratio %f\n", pageRatio); -#define kEffectCuttoffPages 3 if(pageNum >= topPage - kEffectCuttoffPages) { effectVol = (pageNum-kEffectCuttoffPages +1)/(float)(topPage - kEffectCuttoffPages +1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-25 14:38:34
|
Revision: 229 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=229&view=rev Author: mchinen Date: 2010-07-25 14:38:28 +0000 (Sun, 25 Jul 2010) Log Message: ----------- remove forward and back buttons Modified Paths: -------------- NoiseMP3/PlayerView.m Modified: NoiseMP3/PlayerView.m =================================================================== --- NoiseMP3/PlayerView.m 2010-07-25 14:32:04 UTC (rev 228) +++ NoiseMP3/PlayerView.m 2010-07-25 14:38:28 UTC (rev 229) @@ -936,43 +936,43 @@ glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, backImgInfo.texture_id ); +// +//glBegin( GL_QUADS ); +// glTexCoord2f (0.0f,0.0f); +// glVertex2f( x1, y1 ); +// glTexCoord2f (1.0f,0.0f); +// glVertex2f( x2, y1 ); +// glTexCoord2f (1.0f,1.0f); +// glVertex2f( x2, y2 ); +// glTexCoord2f (0.0f,1.0f); +// glVertex2f( x1, y2 ); +//glEnd(); +// +// x1 = kForwardButtonXRatio; +// x2 = x1+widthGL; +// y1 = kButtonYRatio; +// y2 = y1+heightGL; +// +// //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) +// x1 = 2*x1-1.0; +// x2 = 2*x2-1.0; +// y1 = y1*-2 + 1.0; +// y2 = y2*-2 + 1.0; +// +// glEnable( GL_TEXTURE_2D ); +// glBindTexture( GL_TEXTURE_2D, forwardImgInfo.texture_id ); +// +//glBegin( GL_QUADS ); +// glTexCoord2f (0.0f,0.0f); +// glVertex2f( x1, y1 ); +// glTexCoord2f (1.0f,0.0f); +// glVertex2f( x2, y1 ); +// glTexCoord2f (1.0f,1.0f); +// glVertex2f( x2, y2 ); +// glTexCoord2f (0.0f,1.0f); +// glVertex2f( x1, y2 ); +//glEnd(); -glBegin( GL_QUADS ); - glTexCoord2f (0.0f,0.0f); - glVertex2f( x1, y1 ); - glTexCoord2f (1.0f,0.0f); - glVertex2f( x2, y1 ); - glTexCoord2f (1.0f,1.0f); - glVertex2f( x2, y2 ); - glTexCoord2f (0.0f,1.0f); - glVertex2f( x1, y2 ); -glEnd(); - - x1 = kForwardButtonXRatio; - x2 = x1+widthGL; - y1 = kButtonYRatio; - y2 = y1+heightGL; - - //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) - x1 = 2*x1-1.0; - x2 = 2*x2-1.0; - y1 = y1*-2 + 1.0; - y2 = y2*-2 + 1.0; - - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, forwardImgInfo.texture_id ); - -glBegin( GL_QUADS ); - glTexCoord2f (0.0f,0.0f); - glVertex2f( x1, y1 ); - glTexCoord2f (1.0f,0.0f); - glVertex2f( x2, y1 ); - glTexCoord2f (1.0f,1.0f); - glVertex2f( x2, y2 ); - glTexCoord2f (0.0f,1.0f); - glVertex2f( x1, y2 ); -glEnd(); - PNGInfo* volumeImgInfo; switch([controller getVolumeState]) { case eQuiet: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-25 14:32:10
|
Revision: 228 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=228&view=rev Author: mchinen Date: 2010-07-25 14:32:04 +0000 (Sun, 25 Jul 2010) Log Message: ----------- fixing blend setting for control bar Modified Paths: -------------- NoiseMP3/PlayerView.m Modified: NoiseMP3/PlayerView.m =================================================================== --- NoiseMP3/PlayerView.m 2010-07-25 14:14:57 UTC (rev 227) +++ NoiseMP3/PlayerView.m 2010-07-25 14:32:04 UTC (rev 228) @@ -573,6 +573,9 @@ glVertex3f(cursorX, cursorY2, 0.0f ); } glEnd(); + + glDisable(GL_BLEND); // for text fading + // [context setShouldAntialias:YES]; } @@ -904,6 +907,9 @@ y1 = y1*-2 + 1.0; y2 = y2*-2 + 1.0; //it is just a rectange of height with the text + + glEnable(GL_BLEND); // for text fading + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); // ditto glBegin(GL_POLYGON); glColor4f(1.0,1.0,1.0,1.0); glVertex2f(x2, y2); @@ -1034,6 +1040,8 @@ [self drawText:activityString atGLX:x1 atGLY:y1 atEnd:NO]; [activityString release]; } + + glDisable(GL_BLEND); // for text fading } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-25 14:15:03
|
Revision: 227 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=227&view=rev Author: mchinen Date: 2010-07-25 14:14:57 +0000 (Sun, 25 Jul 2010) Log Message: ----------- Fix off by one pixel errors. Fix Notehead width. Use layer depth to compute synth volume. Only play nonchirp synths for new events. Modified Paths: -------------- NoiseMP3/ChirpSynth.cpp NoiseMP3/DelaySynth.cpp NoiseMP3/DownsampleSynth.cpp NoiseMP3/GUINoiseSynth.cpp NoiseMP3/GranularSynth.cpp NoiseMP3/PlayerModel.mm NoiseMP3/PlayerView.m NoiseMP3/SongActivityList.h NoiseMP3/SongActivityList.m NoiseMP3/SongActivityPage.h NoiseMP3/SongActivityPage.m NoiseMP3/UserActivity.h NoiseMP3/UserActivity.mm Modified: NoiseMP3/ChirpSynth.cpp =================================================================== --- NoiseMP3/ChirpSynth.cpp 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/ChirpSynth.cpp 2010-07-25 14:14:57 UTC (rev 227) @@ -50,8 +50,8 @@ { outValue=ComputeSample() * amp * m_volume; - ((float**)outBufs)[0][outCursor]+= outValue * (1.0-pan); - ((float**)outBufs)[1][outCursor]+= outValue * pan; + ((float**)outBufs)[0][outCursor]+= outValue * (1.0-pan) * m_volume; + ((float**)outBufs)[1][outCursor]+= outValue * pan * m_volume; } Modified: NoiseMP3/DelaySynth.cpp =================================================================== --- NoiseMP3/DelaySynth.cpp 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/DelaySynth.cpp 2010-07-25 14:14:57 UTC (rev 227) @@ -15,7 +15,7 @@ #define SR 44100 #define PI 3.1415926 -#define kGranLifetime 44100*20 +#define kGranLifetime 44100*6 DelaySynth::DelaySynth(UserActivity* act) :Synth(act) { Modified: NoiseMP3/DownsampleSynth.cpp =================================================================== --- NoiseMP3/DownsampleSynth.cpp 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/DownsampleSynth.cpp 2010-07-25 14:14:57 UTC (rev 227) @@ -15,7 +15,7 @@ #define SR 44100 #define PI 3.1415926 -#define kGranLifetime 44100*20 +#define kGranLifetime 44100*6 DownsampleSynth::DownsampleSynth(UserActivity* act) :Synth(act) { @@ -98,9 +98,8 @@ float filter_state2 =0.0; /* input_buf can be equal to output_buf */ -static void downsample_interleaved( float *input_buf, float *output_buf,int downsampleRatio, int output_count, int num_chans, int targetChan ) { +static void downsample_interleaved( float *input_buf, float *output_buf,int downsampleRatio, int output_count, int num_chans, int targetChan, float volume) { int input_idx, input_end, output_idx; - float output_sam; float next_sam; float* filter_state; for(int i=0;i<num_chans;i++){ @@ -117,7 +116,7 @@ for(int j=0;j<downsampleRatio;j++) { dcursor = ((float)(j+1)/downsampleRatio); - output_buf[ output_idx] = dcursor * next_sam + (1.0-dcursor)* *filter_state; + output_buf[ output_idx] = dcursor * next_sam + (1.0-dcursor)* *filter_state * volume; output_idx+=num_chans; } @@ -136,9 +135,9 @@ if(actualdsl>1) - downsample_interleaved( outBufs[0],outBufs[0],actualdsl, framesPerBuffer,1, 0 ); + downsample_interleaved( outBufs[0],outBufs[0],actualdsl, framesPerBuffer,1, 0, m_volume ); if(actualdsr>1) - downsample_interleaved( outBufs[1],outBufs[1],actualdsr, framesPerBuffer,1, 1 ); + downsample_interleaved( outBufs[1],outBufs[1],actualdsr, framesPerBuffer,1, 1, m_volume ); lifetime-=framesPerBuffer; } Modified: NoiseMP3/GUINoiseSynth.cpp =================================================================== --- NoiseMP3/GUINoiseSynth.cpp 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/GUINoiseSynth.cpp 2010-07-25 14:14:57 UTC (rev 227) @@ -12,7 +12,7 @@ #include "handyfuncs.h" #import "UserActivity.h" -#define kNoiseLifetime 44100*10 +#define kNoiseLifetime 44100*6 GUINoiseSynth::GUINoiseSynth(UserActivity* act) :Synth(act) Modified: NoiseMP3/GranularSynth.cpp =================================================================== --- NoiseMP3/GranularSynth.cpp 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/GranularSynth.cpp 2010-07-25 14:14:57 UTC (rev 227) @@ -15,7 +15,7 @@ #define SR 44100 #define PI 3.1415926 -#define kGranLifetime 44100*20 +#define kGranLifetime 44100*6 GranularSynth::GranularSynth(UserActivity* act) :Synth(act) { Modified: NoiseMP3/PlayerModel.mm =================================================================== --- NoiseMP3/PlayerModel.mm 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/PlayerModel.mm 2010-07-25 14:14:57 UTC (rev 227) @@ -327,40 +327,59 @@ //always add chirp. - synth = new ChirpSynth(act); - synth->SetVolume(1.0); - FuckingAudioIO::Instance()->AddSynth(synth); //use a loose psuedorandom technique to make sure we get a good mix of synths, but //a result that is deterministic based on cursor start time. float cursor = [act getCursor]; int diceCursor = cursor*100; - if( (diceCursor*39) %17 < 5) + + //make volume softer based on layer number + float pageRatio; + float effectVol; + int topPage = [[self getSongActivityList] getSelectedPage]; + int pageNum = [[act getPage] getPageNumber]; + + + pageRatio = (pageNum+1) /(float)(topPage + 1); + pageRatio = pageRatio < 0.2 ? 0.2 : pageRatio; + + + synth = new ChirpSynth(act); + synth->SetVolume(pageRatio); + FuckingAudioIO::Instance()->AddSynth(synth); + printf("pageratio %f\n", pageRatio); + +#define kEffectCuttoffPages 3 + if(pageNum >= topPage - kEffectCuttoffPages) { - synth = new GranularSynth(act); - synth->SetVolume(1.0); - FuckingAudioIO::Instance()->AddSynth(synth); - } - if( (diceCursor*19) %17 <5 ) - { - synth = new GUINoiseSynth(act); - synth->SetVolume(1.0); - FuckingAudioIO::Instance()->AddSynth(synth); - } - if( (diceCursor*193) %10 < 5) - { - - synth = new DelaySynth(act); - synth->SetVolume(1.0); - FuckingAudioIO::Instance()->AddSynth(synth); + effectVol = (pageNum-kEffectCuttoffPages +1)/(float)(topPage - kEffectCuttoffPages +1); + if( (diceCursor*39) %17 < 5) + { + synth = new GranularSynth(act); + synth->SetVolume(effectVol); + FuckingAudioIO::Instance()->AddSynth(synth); + } + if( (diceCursor*19) %17 <5 ) + { + synth = new GUINoiseSynth(act); + synth->SetVolume(effectVol); + FuckingAudioIO::Instance()->AddSynth(synth); + } + if( (diceCursor*193) %10 < 5) + { + + synth = new DelaySynth(act); + synth->SetVolume(effectVol); + FuckingAudioIO::Instance()->AddSynth(synth); + } + if( (diceCursor*437) %10 < 3) + { + + synth = new DownsampleSynth(act); + synth->SetVolume(effectVol); + FuckingAudioIO::Instance()->AddSynth(synth); + } } - if( (diceCursor*437) %10 < 3) - { - - synth = new DownsampleSynth(act); - synth->SetVolume(1.0); - FuckingAudioIO::Instance()->AddSynth(synth); - } } - (void) play Modified: NoiseMP3/PlayerView.m =================================================================== --- NoiseMP3/PlayerView.m 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/PlayerView.m 2010-07-25 14:14:57 UTC (rev 227) @@ -535,14 +535,11 @@ -(void) drawCursor:(float) cursor lineWidth:(int)width isBlack:(bool)isBlack { - unsigned char* bitmap = [renderBitmap bitmapData]; - float cursorWidth = 2.0/[renderBitmap pixelsWide];//this is actually half the width of the thick line (since we scale by 2) +// float cursorWidth = 2.0/[renderBitmap pixelsWide];//this is actually half the width of the thick line (since we scale by 2) + float cursorWidth = 0.5/[renderBitmap pixelsWide];//this is actually half the width of the thick line (since we scale by 2) -// int cursorX = ([renderBitmap pixelsWide]-kPlayBarMargin*2)*cursor+kPlayBarMargin; -// int cursorY1 = [renderBitmap pixelsHigh]*kPlayBarYRatio; -// int cursorY2 = cursorY1+kPlayBarHeight; - float cursorX = (1.0-kPlayBarMarginGL*2)*cursor+kPlayBarMarginGL; + cursorX = ((int)(cursorX/cursorWidth))*cursorWidth; float cursorY1 = kPlayBarYRatio; float cursorY2 = cursorY1+kPlayBarHeightGL; @@ -550,47 +547,32 @@ cursorX = 2*cursorX-1.0; cursorY1 = cursorY1*-2 + 1.0; cursorY2 = cursorY2*-2 + 1.0; - - //we don't want the main playhead to overwrite our black lines from the activity - //if(cursorX<lastBlackCursorX+cursorWidth) - // return; - -// [context setShouldAntialias:NO]; - -//OLD Cocoa draw -/* - NSBezierPath* path = [NSBezierPath bezierPath]; - [path moveToPoint:NSMakePoint(cursorX,cursorY1)]; - [path lineToPoint:NSMakePoint(cursorX,cursorY2)]; - [path setLineWidth:width]; - [path stroke]; -*/ - -if(lastCursor-.25 > cursor) - cyclehack++; -lastCursor=cursor; - -glEnable(GL_BLEND); // for text fading -glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); // ditto - -glLineWidth(width); -glBegin( GL_LINES ); -{ - if(isBlack) - glColor4f(0.0,0.0,0.0,1.0); - else - { - if(cyclehack%2==1) - glColor4f(0.0,0.0,0.0,0.1); + + if(lastCursor-.25 > cursor) + cyclehack++; + lastCursor=cursor; + + glEnable(GL_BLEND); // for text fading + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); // ditto + + glLineWidth(width); + glBegin( GL_LINES ); + { + if(isBlack) + glColor4f(0.0,0.0,0.0,1.0); else - glColor4f(0.16,0.16,0.16,0.1); + { + if(cyclehack%2==1) + glColor4f(0.0,0.0,0.0,0.1); + else + glColor4f(0.16,0.16,0.16,0.1); + } + glVertex3f(cursorX, cursorY1, 0.0f ); + + glVertex3f(cursorX, cursorY2, 0.0f ); } - glVertex3f(cursorX, cursorY1, 0.0f ); - - glVertex3f(cursorX, cursorY2, 0.0f ); -} -glEnd(); + glEnd(); // [context setShouldAntialias:YES]; } @@ -623,14 +605,13 @@ -(void) drawActivity:(UserActivity*) activity { - unsigned char* bitmap = [renderBitmap bitmapData]; float cursor = [activity getCursor];//[controller getPlaybackCursor]; - float pixelWidth = 1.0f/[renderBitmap pixelsHigh]; + float pixelWidth = 1.0f/[renderBitmap pixelsWide]; float textHeight = ((float)kTextHeight)/[renderBitmap pixelsHigh]; float textOffset = ((float)kTextOffset)/[renderBitmap pixelsHigh]; float noteheadWidth = kNoteheadWidth*pixelWidth; - pixelWidth = pixelWidth/2.0; //convert to gl scale + pixelWidth = pixelWidth;///2.0; //convert to gl scale //for now just draw a line at the cursor. // int cursorX = ([renderBitmap pixelsWide]-kPlayBarMargin*2)*cursor+kPlayBarMargin; @@ -836,7 +817,7 @@ //also draw a notehead on the end of the line. float cursorX2; float cursorRectY; - cursorX2= cursorXNonFlipped + (cursor<0.5?noteheadWidth:(-1*noteheadWidth)); + cursorX2= cursorXNonFlipped + (cursor<0.5?noteheadWidth:(-1*(noteheadWidth - pixelWidth))); cursorRectY= cursorY2NonFlipped + (cursor<0.5?-1*textHeight:textHeight); cursorX2 = 2*cursorX2-1.0; cursorRectY = cursorRectY*-2.0 + 1.0; @@ -845,7 +826,7 @@ glEnable(GL_BLEND); // for text fading glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // ditt - //stem + //notehead //it is just a rectange of height with the text glBegin(GL_POLYGON); glColor4f(0.0,0.0,0.0,1.0); @@ -861,7 +842,10 @@ //if we're past the center, we do a right align [self createAndDrawActivityText:activity x:textX y:textY grayText:NO]; //finally draw a line for the cursor on the bar. - [self drawCursor:cursor lineWidth:1.0 isBlack:cursor]; + [self drawCursor:cursor lineWidth:1.0 isBlack:YES]; + + + //[self drawLineX:cursorX y1:cursorY1 y2:cursorY2]; //save the x so that we don't overwrite it with the main playhead lastBlackCursorX=cursorX; } Modified: NoiseMP3/SongActivityList.h =================================================================== --- NoiseMP3/SongActivityList.h 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/SongActivityList.h 2010-07-25 14:14:57 UTC (rev 227) @@ -36,4 +36,5 @@ - (UserActivity*) getMostRecentUserActivity; - (int) getNumPages; - (UserActivity*) getUserActivityAtCursor:(float) cursor; +- (int) getSelectedPage; @end Modified: NoiseMP3/SongActivityList.m =================================================================== --- NoiseMP3/SongActivityList.m 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/SongActivityList.m 2010-07-25 14:14:57 UTC (rev 227) @@ -89,7 +89,7 @@ } - (void) addPage { - SongActivityPage* page = [[SongActivityPage alloc] initWithStartTime:[NSDate date]]; + SongActivityPage* page = [[SongActivityPage alloc] initWithStartTime:[NSDate date] pageNumber:[pages count]]; [pages addObject:page]; [page release]; //move the playback layers to the next page as well. @@ -108,12 +108,12 @@ //gets the user activity closest to but not greater than the cursor from everying including and below selected page - (UserActivity*) getUserActivityAtCursor:(float) cursor { - UserActivity *act = NULL, *best = NULL; + UserActivity *act = nil, *best = nil; int i; //for now just return the selected page. This won't scale. for(i=0;i<selectedPage;i++) { act = [[pages objectAtIndex:i] getUserActivityAtCursor:cursor]; - if(!best || [act getCursor] > [best getCursor]) + if(!best || (act != nil && [act getCursor] > [best getCursor]) ) best = act; } @@ -137,6 +137,10 @@ return [pages count]; } +- (int) getSelectedPage +{ + return selectedPage; +} @end Modified: NoiseMP3/SongActivityPage.h =================================================================== --- NoiseMP3/SongActivityPage.h 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/SongActivityPage.h 2010-07-25 14:14:57 UTC (rev 227) @@ -15,11 +15,12 @@ { NSMutableArray* activities; NSDate* startTime; - + int lastCursorIndex; + int pageNumber; } -- (id) initWithStartTime:(NSDate*)time; +- (id) initWithStartTime:(NSDate*)time pageNumber:(int)num; - (id) initWithCoder: (NSCoder *)coder; - (void) encodeWithCoder: (NSCoder *)coder; @@ -29,4 +30,5 @@ - (UserActivity*) getMostRecentUserActivity; - (int) getNumUserActivities; - (UserActivity*) getUserActivityAtCursor:(float) cursor; +- (int) getPageNumber; @end Modified: NoiseMP3/SongActivityPage.m =================================================================== --- NoiseMP3/SongActivityPage.m 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/SongActivityPage.m 2010-07-25 14:14:57 UTC (rev 227) @@ -11,12 +11,13 @@ @implementation SongActivityPage -- (id) initWithStartTime:(NSDate*) time +- (id) initWithStartTime:(NSDate*) time pageNumber:(int)num { if (self = [super init]) { activities = [[NSMutableArray alloc] init]; startTime = [time retain]; + pageNumber = num; } return self; } @@ -25,9 +26,15 @@ { if (self = [super init]) { + int i; lastCursorIndex=0; startTime = [[coder decodeObject] retain]; activities = [[coder decodeObject] retain]; + + [coder decodeValueOfObjCType:@encode(int) at:&pageNumber]; + //set the page for each of our activities + for(i=0; i < [activities count]; i++) + [[activities objectAtIndex:i] setPage:self]; } return self; } @@ -43,6 +50,8 @@ { [coder encodeObject: startTime]; [coder encodeObject: activities]; + + [coder encodeValueOfObjCType:@encode(int) at:&pageNumber]; } @@ -76,6 +85,7 @@ } } + [activity setPage:self]; [activities insertObject:activity atIndex:end]; // [activities addObject:activity]; //increment counter. @@ -89,6 +99,8 @@ } } + +//return the closest activity to cursor that is LESS than the cursor - (UserActivity*) getUserActivityAtCursor:(float) cursor { if(![activities count]) @@ -96,6 +108,10 @@ UserActivity* act = [activities objectAtIndex:lastCursorIndex]; + //the 0th object can be greater than the cursor, in which case NULL should be returned + if([[activities objectAtIndex:0] getCursor] > cursor) + return nil; + //special cse for 1 object if([activities count] == 1) return act; @@ -107,6 +123,7 @@ else next = [activities objectAtIndex:lastCursorIndex+1]; + while(!([act getCursor] <= cursor && [next getCursor] > cursor)) { //special case for first index - return the last index if we haven't hit it yet. @@ -153,4 +170,8 @@ return [activities count]; } +- (int) getPageNumber +{ + return pageNumber; +} @end Modified: NoiseMP3/UserActivity.h =================================================================== --- NoiseMP3/UserActivity.h 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/UserActivity.h 2010-07-25 14:14:57 UTC (rev 227) @@ -8,7 +8,7 @@ #import <Cocoa/Cocoa.h> - +@class SongActivityPage; @interface UserActivity : NSObject <NSCoding> { //the time this activity was logged @@ -20,6 +20,7 @@ //a string description of the window title NSString* title; + SongActivityPage *parent; //NSMutableDictionary * properties; } @@ -31,4 +32,7 @@ -(NSString*) getName; -(NSString*) getTitle; +-(SongActivityPage*) getPage; +-(void)setPage:(SongActivityPage*)page; + @end Modified: NoiseMP3/UserActivity.mm =================================================================== --- NoiseMP3/UserActivity.mm 2010-07-24 18:20:36 UTC (rev 226) +++ NoiseMP3/UserActivity.mm 2010-07-25 14:14:57 UTC (rev 227) @@ -8,7 +8,6 @@ #import "UserActivity.h" - @implementation UserActivity -initWithTime:(CFAbsoluteTime) t cursorTime:(float)c nameString:(NSString*)n titleString:(NSString*) ts { @@ -18,7 +17,7 @@ // NSArray * values = [NSArray arrayWithObjects: t, [NSNumber numberWithFloat:c], n, ts, nil]; // properties = [[NSMutableDictionary alloc] initWithObjects: values forKeys: keys]; - + parent = nil; time =t; cursor =c; name=n; @@ -64,4 +63,8 @@ -(float) getCursor { return cursor; } -(NSString*) getName { return name; } -(NSString*) getTitle { return title;} +-(SongActivityPage*) getPage;{return parent;} +-(void)setPage:(SongActivityPage*)page;{parent = page;} + + @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-24 18:20:43
|
Revision: 226 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=226&view=rev Author: mchinen Date: 2010-07-24 18:20:36 +0000 (Sat, 24 Jul 2010) Log Message: ----------- Add layer/page concept. NOTE: after this change you need to delete all previous .activity files in ~/Library/Application Support/MiruTune/ Modified Paths: -------------- NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj NoiseMP3/PlayerModel.h NoiseMP3/PlayerModel.mm NoiseMP3/SongActivityList.h NoiseMP3/SongActivityList.m Added Paths: ----------- NoiseMP3/SongActivityPage.h NoiseMP3/SongActivityPage.m Modified: NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj =================================================================== --- NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj 2010-07-21 15:06:05 UTC (rev 225) +++ NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj 2010-07-24 18:20:36 UTC (rev 226) @@ -38,6 +38,7 @@ 18CE4428114DB0FC00282C50 /* Synth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18CE4427114DB0FC00282C50 /* Synth.cpp */; }; 18CE4430114DB3EF00282C50 /* GUINoiseSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18CE442F114DB3EF00282C50 /* GUINoiseSynth.cpp */; }; 18CE4487114F2C9E00282C50 /* PulseSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18CE4486114F2C9D00282C50 /* PulseSynth.cpp */; }; + 84985A2211FB4AE70039F1EC /* SongActivityPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 84985A2111FB4AE70039F1EC /* SongActivityPage.m */; }; 84EAAC0C11AF149700223A1C /* ChirpSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAAC0B11AF149700223A1C /* ChirpSynth.cpp */; }; 84EAACEC11AF267C00223A1C /* DelaySynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAACEB11AF267C00223A1C /* DelaySynth.cpp */; }; 84EAAF0D11B2FCE900223A1C /* DownsampleSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAAF0C11B2FCE900223A1C /* DownsampleSynth.cpp */; }; @@ -113,6 +114,8 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 32CA4F630368D1EE00C91783 /* NoiseMP3_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoiseMP3_Prefix.pch; sourceTree = "<group>"; }; + 84985A2011FB4AE70039F1EC /* SongActivityPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SongActivityPage.h; sourceTree = "<group>"; }; + 84985A2111FB4AE70039F1EC /* SongActivityPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SongActivityPage.m; sourceTree = "<group>"; }; 84EAAC0A11AF149700223A1C /* ChirpSynth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChirpSynth.h; sourceTree = "<group>"; }; 84EAAC0B11AF149700223A1C /* ChirpSynth.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = ChirpSynth.cpp; sourceTree = "<group>"; }; 84EAACEA11AF267C00223A1C /* DelaySynth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DelaySynth.h; sourceTree = "<group>"; }; @@ -168,6 +171,8 @@ 1851DEDA116418A0001687A6 /* SongActivityList.m */, 84FAF03E11F52A5900F842E2 /* PlayerWindow.h */, 84FAF04311F52ADB00F842E2 /* PlayerWindow.m */, + 84985A2011FB4AE70039F1EC /* SongActivityPage.h */, + 84985A2111FB4AE70039F1EC /* SongActivityPage.m */, ); name = Classes; sourceTree = "<group>"; @@ -377,6 +382,7 @@ 84EAACEC11AF267C00223A1C /* DelaySynth.cpp in Sources */, 84EAAF0D11B2FCE900223A1C /* DownsampleSynth.cpp in Sources */, 84FAF04411F52ADB00F842E2 /* PlayerWindow.m in Sources */, + 84985A2211FB4AE70039F1EC /* SongActivityPage.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: NoiseMP3/PlayerModel.h =================================================================== --- NoiseMP3/PlayerModel.h 2010-07-21 15:06:05 UTC (rev 225) +++ NoiseMP3/PlayerModel.h 2010-07-24 18:20:36 UTC (rev 226) @@ -40,11 +40,11 @@ } - (id) initWithPlayerController:(PlayerController*) cont; - dealloc; -- play; -- pause; -- chooseAudioFile; +-(void) play; +-(void) pause; +-(void) chooseAudioFile; -(void) loadAudioFile:(NSString*) fileName; -- changeVolume:(int) volumeState; +-(void) changeVolume:(int) volumeState; -(void) saveDataToDisk; //for view - (int)getSongDuration; @@ -57,8 +57,8 @@ //for callback -(NSString*) getLastAppName; - setLastAppName:(NSString*)name; -- (NSString*)getLastTitle; -- setLastTitle:(NSString*)title; +-(NSString*)getLastTitle; +-(void) setLastTitle:(NSString*)title; - (AXUIElementRef)getSystemWideRef; - (SongActivityList*) getSongActivityList; @@ -66,5 +66,5 @@ -(PlayerController*) getController; - (void)addActivity:(UserActivity*) activity; - (UserActivity*)getLastCursorAct; -- setLastCursorAct:(UserActivity*)act; +-(void) setLastCursorAct:(UserActivity*)act; @end Modified: NoiseMP3/PlayerModel.mm =================================================================== --- NoiseMP3/PlayerModel.mm 2010-07-21 15:06:05 UTC (rev 225) +++ NoiseMP3/PlayerModel.mm 2010-07-24 18:20:36 UTC (rev 226) @@ -21,8 +21,8 @@ #include "GranularSynth.h" #include "DelaySynth.h" #include "DownsampleSynth.h" +#include "SongActivityPage.h" - @implementation PlayerModel @@ -118,7 +118,7 @@ { playbackCursor = ((float)sample/sampleRate)/songDuration; } -- changeVolume:(int) volumeState +-(void) changeVolume:(int) volumeState { float amp; //use logarthmic curve. @@ -146,7 +146,7 @@ return lastAppName; } -- setLastAppName:(NSString*)name +-(void) setLastAppName:(NSString*)name { if(lastAppName) [lastAppName release]; @@ -156,7 +156,7 @@ { return lastTitle; } -- setLastTitle:(NSString*)title +-(void) setLastTitle:(NSString*)title { if(lastTitle) [lastTitle release]; @@ -208,13 +208,20 @@ { return lastCursorAct; } -- setLastCursorAct:(UserActivity*)act +-(void) setLastCursorAct:(UserActivity*)act { lastCursorAct = act; } void snifferTimerCallBack(CFRunLoopTimerRef timer, void *info) { PlayerModel *model = (PlayerModel *)info; + static float lastPlaybackCursor=10000; + //check cursor to see if we should make a new page. + if([model getPlaybackCursor] < lastPlaybackCursor) { + [[model getSongActivityList] addPage]; + } + lastPlaybackCursor = [model getPlaybackCursor]; + //first check the cursor to see if we've moved on. UserActivity* thisCursorAct = [[model getSongActivityList] getUserActivityAtCursor:[model getPlaybackCursor] ]; @@ -356,7 +363,7 @@ } } -- play +- (void) play { //only do something if we have an mp3 at hand. //if we do set the play button to show we are playing @@ -388,11 +395,17 @@ int length =decoder->OpenFile(); if(length) { + SongActivityPage* page; [controller changeDisplayFilename:[NSString stringWithFormat:@"%@ (%is)",[currentFilename lastPathComponent],length]]; //display whatever activities are in there. - for(int i=0;i<[activities getNumUserActivities];i++) - [[self getController] displayUserActivity:[activities getUserActivityAtIndex:i]]; + for(int i=0;i<[activities getNumPages];i++) { + page = [activities getPageAtIndex:i]; + for(int j=0;j<[page getNumUserActivities];j++) { + [[self getController] displayUserActivity:[page getUserActivityAtIndex:j]]; + } + } + songDuration= length; decoder->Start(); FuckingAudioIO::Instance()->SetMP3Decoder(decoder); @@ -444,7 +457,7 @@ CFRunLoopAddTimer(CFRunLoopGetCurrent(), snifferTimer, kCFRunLoopCommonModes); } -- pause +- (void)pause { //stop the sniffing CFRunLoopTimerInvalidate(snifferTimer); @@ -454,7 +467,7 @@ FuckingAudioIO::Instance()->Stop(); } -- chooseAudioFile +- (void)chooseAudioFile { NSOpenPanel* openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseFiles:YES]; Modified: NoiseMP3/SongActivityList.h =================================================================== --- NoiseMP3/SongActivityList.h 2010-07-21 15:06:05 UTC (rev 225) +++ NoiseMP3/SongActivityList.h 2010-07-24 18:20:36 UTC (rev 226) @@ -11,11 +11,13 @@ #define kMaxActivities 500 @class UserActivity; +@class SongActivityPage; @interface SongActivityList : NSObject <NSCoding> { - NSMutableArray* activities; + NSMutableArray* pages; NSString* songFileName; int lastCursorIndex; + int selectedPage; } - (id) initWithSongFileName:(NSString*)str; @@ -25,10 +27,13 @@ +(SongActivityList*) loadSongActivityList:(NSString*)songname; +(BOOL) songDataExists:(NSString*)songname; +//adds a page using the current date. +- (void) addPage; +//adds a user activity to the last page at the current date. +- (void) addUserActivity:(UserActivity*)activity; -- (void) addUserActivity:(UserActivity*)activity; -- (UserActivity*) getUserActivityAtIndex:(int)index; +- (SongActivityPage*) getPageAtIndex:(int)index; - (UserActivity*) getMostRecentUserActivity; -- (int) getNumUserActivities; +- (int) getNumPages; - (UserActivity*) getUserActivityAtCursor:(float) cursor; @end Modified: NoiseMP3/SongActivityList.m =================================================================== --- NoiseMP3/SongActivityList.m 2010-07-21 15:06:05 UTC (rev 225) +++ NoiseMP3/SongActivityList.m 2010-07-24 18:20:36 UTC (rev 226) @@ -7,6 +7,7 @@ // #import "SongActivityList.h" +#import "SongActivityPage.h" #import "UserActivity.h" @implementation SongActivityList @@ -15,8 +16,8 @@ { if (self = [super init]) { - lastCursorIndex=0; - activities = [[NSMutableArray alloc] init]; + selectedPage =-1; + pages = [[NSMutableArray alloc] init]; songFileName = [str retain]; } return self; @@ -26,23 +27,24 @@ { if (self = [super init]) { - lastCursorIndex=0; - activities = [[coder decodeObject] retain]; + pages = [[coder decodeObject] retain]; songFileName = [[coder decodeObject] retain]; + selectedPage = [pages count] -1; + } return self; } - (void) dealloc { - [activities release]; + [pages release]; [songFileName release]; [super dealloc]; } - (void) encodeWithCoder: (NSCoder *)coder { - [coder encodeObject: activities]; + [coder encodeObject: pages]; [coder encodeObject: songFileName]; } @@ -79,119 +81,60 @@ rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; return [rootObject retain]; } + +(BOOL) songDataExists:(NSString*)songname { return [[NSFileManager defaultManager] fileExistsAtPath: [SongActivityList pathForDataFile:songname]]; } +- (void) addPage { + SongActivityPage* page = [[SongActivityPage alloc] initWithStartTime:[NSDate date]]; + [pages addObject:page]; + [page release]; + //move the playback layers to the next page as well. + selectedPage++; +} - (void) addUserActivity:(UserActivity*)activity { - //TODO: add with sort behavior. - //do binary search - int beg=0; //this is where we insert - int end = [activities count]; - int mid=-1; - UserActivity* testAct = nil; - //go until we hve difference of 1 - while(end-beg != 0) - { - //check for the condition when we are seperated by one and stuck - mid = (beg+end)/2; //if they are one seperated by just 1, this can round down - testAct = [activities objectAtIndex:mid]; + if(![pages count]) + return; - if([testAct getCursor] < [activity getCursor]) - beg = mid + 1; - else - { - end = mid; - //check for end condition to avoid loop - if(end-beg == 1) - { - testAct = [activities objectAtIndex:beg]; - if([testAct getCursor] < [activity getCursor]) - break; //insert at end - this is a hack to break while loop. - } - } - } - - [activities insertObject:activity atIndex:end]; -// [activities addObject:activity]; - //increment counter. - - //remove the first few ones if we've passed our limit. - while([activities count] > kMaxActivities) - { - //remove the first one - this should release them as well. - //todo find the oldest and remove it. - [activities removeObjectAtIndex:0]; - } + //add to the last page. + [[pages lastObject] addUserActivity:activity]; } +//gets the user activity closest to but not greater than the cursor from everying including and below selected page - (UserActivity*) getUserActivityAtCursor:(float) cursor { - if(![activities count]) - return nil; - - UserActivity* act = [activities objectAtIndex:lastCursorIndex]; - - //special cse for 1 object - if([activities count] == 1) - return act; - - UserActivity* next; - //we need to insert a fake entry for the first entry for the test condition to work - if(lastCursorIndex==[activities count]-1) - next = [[UserActivity alloc] initWithTime:0 cursorTime:10000.0f nameString:@"" titleString:@""]; - else - next = [activities objectAtIndex:lastCursorIndex+1]; - - while(!([act getCursor] <= cursor && [next getCursor] > cursor)) - { - //special case for first index - return the last index if we haven't hit it yet. - if(lastCursorIndex ==0 && cursor<[act getCursor]) - { - act = [activities objectAtIndex:[activities count]-1]; - break; - } - //if we created something deleted it after the test. - if(lastCursorIndex==[activities count]-1) - [next release]; - lastCursorIndex++; - if(lastCursorIndex >= [activities count]) - lastCursorIndex = 0; - //update the pointers - act = [activities objectAtIndex:lastCursorIndex]; - //we need to insert a fake entry for the first entry for the test condition to work - if(lastCursorIndex==[activities count]-1) - next = [[UserActivity alloc] initWithTime:0 cursorTime:10000.0f nameString:@"" titleString:@""]; - else - next = [activities objectAtIndex:lastCursorIndex+1]; + UserActivity *act = NULL, *best = NULL; + int i; + //for now just return the selected page. This won't scale. + for(i=0;i<selectedPage;i++) { + act = [[pages objectAtIndex:i] getUserActivityAtCursor:cursor]; + if(!best || [act getCursor] > [best getCursor]) + best = act; } - //if we created something deleted it after the test. - if(lastCursorIndex==[activities count]-1) - [next release]; - - - return act; + + return best; } -- (UserActivity*) getUserActivityAtIndex:(int)index +- (SongActivityPage*) getPageAtIndex:(int)index { - [activities objectAtIndex:index]; + return [pages objectAtIndex:index]; } - (UserActivity*) getMostRecentUserActivity { - if([activities count]) - return [activities objectAtIndex:[activities count]-1]; + if([pages count]) + return [[pages lastObject] getMostRecentUserActivity]; return NULL; } -- (int) getNumUserActivities +- (int) getNumPages { - [activities count]; + return [pages count]; } Added: NoiseMP3/SongActivityPage.h =================================================================== --- NoiseMP3/SongActivityPage.h (rev 0) +++ NoiseMP3/SongActivityPage.h 2010-07-24 18:20:36 UTC (rev 226) @@ -0,0 +1,32 @@ +// +// SongActivityPage.h +// NoiseMP3 +// +// Created by Administrator on 7/24/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import <Cocoa/Cocoa.h> + +#define kMaxActivities 500 + +@class UserActivity; +@interface SongActivityPage : NSObject <NSCoding> +{ + NSMutableArray* activities; + NSDate* startTime; + + int lastCursorIndex; +} + +- (id) initWithStartTime:(NSDate*)time; +- (id) initWithCoder: (NSCoder *)coder; + +- (void) encodeWithCoder: (NSCoder *)coder; + +- (void) addUserActivity:(UserActivity*)activity; +- (UserActivity*) getUserActivityAtIndex:(int)index; +- (UserActivity*) getMostRecentUserActivity; +- (int) getNumUserActivities; +- (UserActivity*) getUserActivityAtCursor:(float) cursor; +@end Added: NoiseMP3/SongActivityPage.m =================================================================== --- NoiseMP3/SongActivityPage.m (rev 0) +++ NoiseMP3/SongActivityPage.m 2010-07-24 18:20:36 UTC (rev 226) @@ -0,0 +1,156 @@ +// +// SongActivityPage.m +// NoiseMP3 +// +// Created by Administrator on 7/24/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "SongActivityPage.h" +#import "UserActivity.h" + +@implementation SongActivityPage + +- (id) initWithStartTime:(NSDate*) time +{ + if (self = [super init]) + { + activities = [[NSMutableArray alloc] init]; + startTime = [time retain]; + } + return self; +} + +- (id) initWithCoder: (NSCoder *)coder +{ + if (self = [super init]) + { + lastCursorIndex=0; + startTime = [[coder decodeObject] retain]; + activities = [[coder decodeObject] retain]; + } + return self; +} + +- (void) dealloc +{ + [startTime release]; + [activities release]; + [super dealloc]; +} + +- (void) encodeWithCoder: (NSCoder *)coder +{ + [coder encodeObject: startTime]; + [coder encodeObject: activities]; +} + + +- (void) addUserActivity:(UserActivity*)activity +{ + //TODO: add with sort behavior. + //do binary search + int beg=0; //this is where we insert + int end = [activities count]; + int mid=-1; + UserActivity* testAct = nil; + //go until we hve difference of 1 + while(end-beg != 0) + { + //check for the condition when we are seperated by one and stuck + mid = (beg+end)/2; //if they are one seperated by just 1, this can round down + testAct = [activities objectAtIndex:mid]; + + if([testAct getCursor] < [activity getCursor]) + beg = mid + 1; + else + { + end = mid; + //check for end condition to avoid loop + if(end-beg == 1) + { + testAct = [activities objectAtIndex:beg]; + if([testAct getCursor] < [activity getCursor]) + break; //insert at end - this is a hack to break while loop. + } + } + } + + [activities insertObject:activity atIndex:end]; +// [activities addObject:activity]; + //increment counter. + + //remove the first few ones if we've passed our limit. + while([activities count] > kMaxActivities) + { + //remove the first one - this should release them as well. + //todo find the oldest and remove it. + [activities removeObjectAtIndex:0]; + } +} + +- (UserActivity*) getUserActivityAtCursor:(float) cursor +{ + if(![activities count]) + return nil; + + UserActivity* act = [activities objectAtIndex:lastCursorIndex]; + + //special cse for 1 object + if([activities count] == 1) + return act; + + UserActivity* next; + //we need to insert a fake entry for the first entry for the test condition to work + if(lastCursorIndex==[activities count]-1) + next = [[UserActivity alloc] initWithTime:0 cursorTime:10000.0f nameString:@"" titleString:@""]; + else + next = [activities objectAtIndex:lastCursorIndex+1]; + + while(!([act getCursor] <= cursor && [next getCursor] > cursor)) + { + //special case for first index - return the last index if we haven't hit it yet. + if(lastCursorIndex ==0 && cursor<[act getCursor]) + { + act = [activities objectAtIndex:[activities count]-1]; + break; + } + //if we created something deleted it after the test. + if(lastCursorIndex==[activities count]-1) + [next release]; + lastCursorIndex++; + if(lastCursorIndex >= [activities count]) + lastCursorIndex = 0; + //update the pointers + act = [activities objectAtIndex:lastCursorIndex]; + //we need to insert a fake entry for the first entry for the test condition to work + if(lastCursorIndex==[activities count]-1) + next = [[UserActivity alloc] initWithTime:0 cursorTime:10000.0f nameString:@"" titleString:@""]; + else + next = [activities objectAtIndex:lastCursorIndex+1]; + } + //if we created something deleted it after the test. + if(lastCursorIndex==[activities count]-1) + [next release]; + + + return act; +} + +- (UserActivity*) getUserActivityAtIndex:(int)index +{ + return [activities objectAtIndex:index]; +} +- (UserActivity*) getMostRecentUserActivity +{ + if([activities count]) + return [activities objectAtIndex:[activities count]-1]; + return NULL; +} + +-(int) getNumUserActivities +{ + return [activities count]; +} + +@end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-21 15:06:12
|
Revision: 225 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=225&view=rev Author: mchinen Date: 2010-07-21 15:06:05 +0000 (Wed, 21 Jul 2010) Log Message: ----------- adding full screen capability. back and forward buttons do nothing. Modified Paths: -------------- NoiseMP3/English.lproj/MainMenu.nib/info.nib NoiseMP3/English.lproj/MainMenu.nib/keyedobjects.nib NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj NoiseMP3/PlayerController.h NoiseMP3/PlayerController.mm NoiseMP3/PlayerView.h NoiseMP3/PlayerView.m Added Paths: ----------- NoiseMP3/backimg.png NoiseMP3/forwardimg.png Modified: NoiseMP3/English.lproj/MainMenu.nib/info.nib =================================================================== --- NoiseMP3/English.lproj/MainMenu.nib/info.nib 2010-07-20 01:39:13 UTC (rev 224) +++ NoiseMP3/English.lproj/MainMenu.nib/info.nib 2010-07-21 15:06:05 UTC (rev 225) @@ -10,7 +10,7 @@ <integer>5</integer> <key>IBOpenObjects</key> <array> - <integer>209</integer> + <integer>2</integer> <integer>136</integer> </array> <key>IBSystem Version</key> Modified: NoiseMP3/English.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj =================================================================== --- NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj 2010-07-20 01:39:13 UTC (rev 224) +++ NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj 2010-07-21 15:06:05 UTC (rev 225) @@ -42,6 +42,8 @@ 84EAACEC11AF267C00223A1C /* DelaySynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAACEB11AF267C00223A1C /* DelaySynth.cpp */; }; 84EAAF0D11B2FCE900223A1C /* DownsampleSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAAF0C11B2FCE900223A1C /* DownsampleSynth.cpp */; }; 84FAF04411F52ADB00F842E2 /* PlayerWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FAF04311F52ADB00F842E2 /* PlayerWindow.m */; }; + 84FAF12A11F68D8F00F842E2 /* backimg.png in Resources */ = {isa = PBXBuildFile; fileRef = 84FAF12811F68D8F00F842E2 /* backimg.png */; }; + 84FAF12B11F68D8F00F842E2 /* forwardimg.png in Resources */ = {isa = PBXBuildFile; fileRef = 84FAF12911F68D8F00F842E2 /* forwardimg.png */; }; 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; @@ -119,6 +121,8 @@ 84EAAF0C11B2FCE900223A1C /* DownsampleSynth.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = DownsampleSynth.cpp; sourceTree = "<group>"; }; 84FAF03E11F52A5900F842E2 /* PlayerWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerWindow.h; sourceTree = "<group>"; }; 84FAF04311F52ADB00F842E2 /* PlayerWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayerWindow.m; sourceTree = "<group>"; }; + 84FAF12811F68D8F00F842E2 /* backimg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = backimg.png; sourceTree = "<group>"; }; + 84FAF12911F68D8F00F842E2 /* forwardimg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = forwardimg.png; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D1107320486CEB800E47090 /* MiruTune.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MiruTune.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -264,6 +268,8 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 84FAF12811F68D8F00F842E2 /* backimg.png */, + 84FAF12911F68D8F00F842E2 /* forwardimg.png */, 18CE3D881145AB9000282C50 /* pause.png */, 18CE3D891145AB9000282C50 /* playing.png */, 18CE3D8A1145AB9000282C50 /* vol25pro.png */, @@ -340,6 +346,8 @@ 18CE3D911145AB9100282C50 /* vol50pro.png in Resources */, 18CE3D921145AB9100282C50 /* vol75pro.png in Resources */, 18CE3D931145AB9100282C50 /* vol100pro.png in Resources */, + 84FAF12A11F68D8F00F842E2 /* backimg.png in Resources */, + 84FAF12B11F68D8F00F842E2 /* forwardimg.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: NoiseMP3/PlayerController.h =================================================================== --- NoiseMP3/PlayerController.h 2010-07-20 01:39:13 UTC (rev 224) +++ NoiseMP3/PlayerController.h 2010-07-21 15:06:05 UTC (rev 225) @@ -33,9 +33,10 @@ }; @interface PlayerController : NSObject { - IBOutlet NSTextField *fileNameField; - IBOutlet NSButton *playButton; - IBOutlet NSButton *volumeButton; +// IBOutlet NSTextField *fileNameField; +// IBOutlet NSButton *playButton; +// IBOutlet NSButton *volumeButton; + NSString* currFileName; IBOutlet PlayerView *playerView; PlayerModel *playerModel; @@ -46,6 +47,7 @@ NSWindow *origWindow; NSWindow *fsWindow; bool fullScreen; + bool volumeStateChanged; } - (id) init; - dealloc; @@ -63,8 +65,11 @@ - displayUserActivity:(UserActivity*)activity; //for view +- (NSString*)getCurrFileName; - (int)getSongDuration; - (float)getPlaybackCursor; +- (enum VolumeState)getVolumeState; +- (bool)volumeStateChanged; - (void) loadAudioFile:(NSString*)fileName; //drag n drop - (void)launchFullScreen:(id)sender; Modified: NoiseMP3/PlayerController.mm =================================================================== --- NoiseMP3/PlayerController.mm 2010-07-20 01:39:13 UTC (rev 224) +++ NoiseMP3/PlayerController.mm 2010-07-21 15:06:05 UTC (rev 225) @@ -17,6 +17,9 @@ { if ( (self = [super init]) != NULL) { + currFileName= NULL; + volumeState = eMedium; + volumeStateChanged = YES; viewTimer=NULL; playerModel = [[PlayerModel alloc] initWithPlayerController:self]; fullScreen = NO; @@ -27,13 +30,13 @@ - (int)getSongDuration{return [playerModel getSongDuration];} - (float)getPlaybackCursor{return [playerModel getPlaybackCursor];} +- (NSString*)getCurrFileName{return currFileName;} - - (void) awakeFromNib { - [playButton setKeyEquivalent:@" "]; - volumeState = eMedium; +// [playButton setKeyEquivalent:@" "]; + [[playerView window] makeFirstResponder:playerView]; [self changeVolume:self]; @@ -77,68 +80,69 @@ volumeState++; if(volumeState>=eNumVolumeStates) volumeState=eQuiet; - + volumeStateChanged = YES; //ask the model to change the volume. [playerModel changeVolume:volumeState]; //load the button image - find out which file we need. - NSString* imgName; - switch(volumeState) - { - case eQuiet: - imgName = @"vol25pro"; - break; - case eMedium: - imgName = @"vol50pro"; - break; - case eLoud: - imgName = @"vol75pro"; - break; - case eLoudest: - imgName = @"vol100pro"; - break; - } - - if(imgName) - { - NSString* im1 = [[NSBundle mainBundle] pathForResource:imgName ofType:@"png"]; - NSURL* url2 = [NSURL fileURLWithPath:im1]; - NSImage *image = [[NSImage alloc] initWithContentsOfURL: url2]; - [volumeButton setImage: image] ; - } +// NSString* imgName; +// switch(volumeState) +// { +// case eQuiet: +// imgName = @"vol25pro"; +// break; +// case eMedium: +// imgName = @"vol50pro"; +// break; +// case eLoud: +// imgName = @"vol75pro"; +// break; +// case eLoudest: +// imgName = @"vol100pro"; +// break; +// } +// +// if(imgName) +// { +// NSString* im1 = [[NSBundle mainBundle] pathForResource:imgName ofType:@"png"]; +// NSURL* url2 = [NSURL fileURLWithPath:im1]; +// NSImage *image = [[NSImage alloc] initWithContentsOfURL: url2]; +// [volumeButton setImage: image] ; +// } } - changeDisplayFilename:(NSString*) newname { //this is when the player should be resetting, so clear [playerView setNeedsErase]; - - [fileNameField setStringValue:newname]; + if(currFileName) + [currFileName release]; + currFileName = [newname retain]; } - displayPlaying { playerState = ePlaying; - [playButton setTitle:@""]; - [playButton setStringValue:@""]; +// [playButton setTitle:@""]; +// [playButton setStringValue:@""]; //contrary to intuition we need to show the pause button while it is playing. NSString* im1 = [[NSBundle mainBundle] pathForResource:@"pause" ofType:@"png"]; NSURL* url2 = [NSURL fileURLWithPath:im1]; NSImage *image = [[NSImage alloc] initWithContentsOfURL: url2]; - [playButton setImage: image] ; +// [playButton setImage: image] ; } - displayPausing { playerState = eNotPlayingOrPaused; - [playButton setTitle:@""]; - [playButton setStringValue:@""]; +// [playButton setTitle:@""]; +// [playButton setStringValue:@""]; //contrary to intuition we need to show the pause button while it is playing. NSString* im1 = [[NSBundle mainBundle] pathForResource:@"playing" ofType:@"png"]; NSURL* url2 = [NSURL fileURLWithPath:im1]; NSImage *image = [[NSImage alloc] initWithContentsOfURL: url2]; - [playButton setImage: image] ; +// [playButton setImage: image] ; } -(void) displayUserActivity:(UserActivity*)activity @@ -247,6 +251,17 @@ } +- (VolumeState)getVolumeState +{ + return (VolumeState) volumeState; +} +- (bool)volumeStateChanged +{ + if(volumeStateChanged){ + volumeStateChanged = YES; + return volumeStateChanged; + } + return NO; +} - @end Modified: NoiseMP3/PlayerView.h =================================================================== --- NoiseMP3/PlayerView.h 2010-07-20 01:39:13 UTC (rev 224) +++ NoiseMP3/PlayerView.h 2010-07-21 15:06:05 UTC (rev 225) @@ -7,6 +7,15 @@ // #import <Cocoa/Cocoa.h> + +#include <OpenGL/gl.h> + +typedef struct PNGInfo { + GLuint texture_id; + int width; + int height; +} PNGInfo; + @class StringTexture; @class PlayerController; @interface PlayerView : NSOpenGLView { @@ -29,9 +38,20 @@ bool fullScreen; NSOpenGLContext* fullScreenOpenGLContext; + + PNGInfo volume25ImgInfo; + PNGInfo volume50ImgInfo; + PNGInfo volume75ImgInfo; + PNGInfo volume100ImgInfo; + PNGInfo backImgInfo; + PNGInfo forwardImgInfo; } - (id)initWithFrame:(NSRect)frame; - dealloc ; + + +- (void)loadTextures; +- (int) loadPNGTexture:(NSString*)imgname outPNGInfo:(PNGInfo*) outPNGInfo; - (void)drawRect:(NSRect)rect; //drag Modified: NoiseMP3/PlayerView.m =================================================================== --- NoiseMP3/PlayerView.m 2010-07-20 01:39:13 UTC (rev 224) +++ NoiseMP3/PlayerView.m 2010-07-21 15:06:05 UTC (rev 225) @@ -13,7 +13,6 @@ #include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CFDate.h> #include <CoreFoundation/CFTimeZone.h> -#include <OpenGL/gl.h> #include <GLUT/glut.h> #include <unistd.h> @@ -76,6 +75,24 @@ bottomActivities = [[NSMutableArray alloc] init]; topActivities = [[NSMutableArray alloc] init]; //get the size of the screen which is frameRect. + //register for drag n drop + [self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]]; + } + return self; +} + + + +- dealloc { + [drawQueue release]; + [bottomActivities release]; + [topActivities release]; + [super dealloc]; +} + +- (void)awakeFromNib { + NSRect frame; + frame = [self frame]; renderBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:frame.size.width pixelsHigh:frame.size.height @@ -108,20 +125,11 @@ [NSGraphicsContext restoreGraphicsState]; + + [self loadTextures]; - //register for drag n drop - [self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]]; - } - return self; } -- dealloc { - [drawQueue release]; - [bottomActivities release]; - [topActivities release]; - [super dealloc]; -} - //override for settings: -(BOOL)preservesContentDuringLiveResize { @@ -194,6 +202,74 @@ cursorState++; [drawQueue addObject:activity]; } + +#pragma mark OpenGL drawing +- (void)loadTextures +{ + if(![self loadPNGTexture:@"vol25pro" outPNGInfo:&volume25ImgInfo]) + NSLog(@"Couldn't load img\n"); + if(![self loadPNGTexture:@"vol50pro" outPNGInfo:&volume50ImgInfo]) + NSLog(@"Couldn't load img\n"); + if(![self loadPNGTexture:@"vol75pro" outPNGInfo:&volume75ImgInfo]) + NSLog(@"Couldn't load img\n"); + if(![self loadPNGTexture:@"vol100pro" outPNGInfo:&volume100ImgInfo]) + NSLog(@"Couldn't load img\n"); + + if(![self loadPNGTexture:@"backimg" outPNGInfo:&backImgInfo]) + NSLog(@"Couldn't load img\n"); + if(![self loadPNGTexture:@"forwardimg" outPNGInfo:&forwardImgInfo]) + NSLog(@"Couldn't load img\n"); +} + + +- (int) loadPNGTexture:(NSString*) imgname outPNGInfo:(PNGInfo*)outPNGInfo +{ + NSBundle *mainBundle; + NSString *path_image; + NSImage *image; + NSBitmapImageRep *bitmap_image_rep; + NSRect image_rect; + int texture_format; + + mainBundle = [NSBundle mainBundle]; + path_image = [mainBundle pathForResource:imgname ofType:@"png"]; + if(!path_image) + return 0; + + image = [[NSImage alloc] initWithContentsOfFile:path_image]; + NSSize imgsize = [image size]; + [image setFlipped:YES]; + + image_rect = NSMakeRect(0, 0, imgsize.width, imgsize.height); + [image lockFocus]; + bitmap_image_rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:image_rect]; + [image unlockFocus]; + + if ([bitmap_image_rep bitsPerPixel] < 32) { + texture_format = GL_RGB; + } else { + texture_format = GL_RGBA; + } + + glGenTextures(1, &outPNGInfo->texture_id); + glBindTexture(GL_TEXTURE_2D, outPNGInfo->texture_id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, texture_format, imgsize.width, imgsize.height, 0, + texture_format, GL_UNSIGNED_BYTE, [bitmap_image_rep bitmapData]); + + outPNGInfo->width = imgsize.width; + outPNGInfo->height = imgsize.height; + + [mainBundle release]; + [image release]; + [bitmap_image_rep release]; + + return 1; +} + + + //position of the bar #define kPlayBarYRatio 0.5 @@ -208,8 +284,8 @@ - (void)drawRect:(NSRect)rect { -if (fullScreen) - [fullScreenOpenGLContext makeCurrentContext]; + if (fullScreen) + [fullScreenOpenGLContext makeCurrentContext]; // [NSGraphicsContext saveGraphicsState]; // NSGraphicsContext* context = [NSGraphicsContext currentContext]; @@ -238,11 +314,14 @@ [bottomActivities release]; bottomActivities = [[NSMutableArray alloc] init]; topActivities = [[NSMutableArray alloc] init]; - - cyclehack =0; lastCursor=0.0; + + [self drawControlBar]; } + else if([controller volumeStateChanged]) + [self drawControlBar]; + [self drawDuration]; // [[NSColor colorWithDeviceWhite:0.9 alpha:0.1] set]; @@ -816,27 +895,181 @@ } -#define kPlayButtonXRatio 0.5 -#define kPlayButtonYRatio 0.08 --(void) drawPlayPauseButton { - -// glBegin(GL_POLYGON); -// -// glColor4f(0.0,0.0,0.0,1.0); -// glVertex2f(0, y2); -// glVertex2f(x2, y1); -// glVertex2f(x1, y1); -// glVertex2f(x1, y2); -// -// glEnd(); +#define kVolumeButtonXRatio 0.05 +#define kBackButtonXRatio 0.4 +#define kCurrFileTextXRatio 0.46 +#define kForwardButtonXRatio 0.56 +#define kButtonYRatio 0.02 +//text may be smaller so needs a bit more Y ratio +#define kFileTextYRatio 0.024 + +-(void) drawControlBar { + float y1,y2,x1,x2; + float widthGL; + float heightGL = ((float)backImgInfo.height + kButtonYRatio * [renderBitmap pixelsHigh])/[renderBitmap pixelsHigh]; + + //erase the toolbar + x1 = 0; + x2 = 1.0; + y1 = 0; + y2 = heightGL; + + //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) + x1 = 2*x1-1.0; + x2 = 2*x2-1.0; + y1 = y1*-2 + 1.0; + y2 = y2*-2 + 1.0; + //it is just a rectange of height with the text + glBegin(GL_POLYGON); + glColor4f(1.0,1.0,1.0,1.0); + glVertex2f(x2, y2); + glVertex2f(x2, y1); + glVertex2f(x1, y1); + glVertex2f(x1, y2); + glEnd(); + + + widthGL = ((float)backImgInfo.width)/[renderBitmap pixelsWide]; + heightGL = ((float)backImgInfo.height)/[renderBitmap pixelsHigh]; + + x1 = kBackButtonXRatio; + x2 = x1+widthGL; + y1 = kButtonYRatio; + y2 = y1+heightGL; + + //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) + x1 = 2*x1-1.0; + x2 = 2*x2-1.0; + y1 = y1*-2 + 1.0; + y2 = y2*-2 + 1.0; + + + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, backImgInfo.texture_id ); + +glBegin( GL_QUADS ); + glTexCoord2f (0.0f,0.0f); + glVertex2f( x1, y1 ); + glTexCoord2f (1.0f,0.0f); + glVertex2f( x2, y1 ); + glTexCoord2f (1.0f,1.0f); + glVertex2f( x2, y2 ); + glTexCoord2f (0.0f,1.0f); + glVertex2f( x1, y2 ); +glEnd(); + + x1 = kForwardButtonXRatio; + x2 = x1+widthGL; + y1 = kButtonYRatio; + y2 = y1+heightGL; + + //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) + x1 = 2*x1-1.0; + x2 = 2*x2-1.0; + y1 = y1*-2 + 1.0; + y2 = y2*-2 + 1.0; + + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, forwardImgInfo.texture_id ); + +glBegin( GL_QUADS ); + glTexCoord2f (0.0f,0.0f); + glVertex2f( x1, y1 ); + glTexCoord2f (1.0f,0.0f); + glVertex2f( x2, y1 ); + glTexCoord2f (1.0f,1.0f); + glVertex2f( x2, y2 ); + glTexCoord2f (0.0f,1.0f); + glVertex2f( x1, y2 ); +glEnd(); + + PNGInfo* volumeImgInfo; + switch([controller getVolumeState]) { + case eQuiet: + volumeImgInfo = &volume25ImgInfo; + break; + case eMedium: + volumeImgInfo = &volume50ImgInfo; + break; + case eLoud: + volumeImgInfo = &volume75ImgInfo; + break; + default: + case eLoudest: + volumeImgInfo = &volume100ImgInfo; + break; + } + + widthGL = ((float)volumeImgInfo->width)/[renderBitmap pixelsWide]; + heightGL = ((float)volumeImgInfo->height)/[renderBitmap pixelsHigh]; + x1 = kVolumeButtonXRatio; + x2 = x1+widthGL; + y1 = kButtonYRatio; + y2 = y1+heightGL; + + //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) + x1 = 2*x1-1.0; + x2 = 2*x2-1.0; + y1 = y1*-2 + 1.0; + y2 = y2*-2 + 1.0; + glBindTexture( GL_TEXTURE_2D, volumeImgInfo->texture_id ); + +glBegin( GL_QUADS ); + glTexCoord2f (0.0f,0.0f); + glVertex2f( x1, y1 ); + glTexCoord2f (1.0f,0.0f); + glVertex2f( x2, y1 ); + glTexCoord2f (1.0f,1.0f); + glVertex2f( x2, y2 ); + glTexCoord2f (0.0f,1.0f); + glVertex2f( x1, y2 ); +glEnd(); + +glDisable( GL_TEXTURE_2D ); + + + //file name text + //create texture + if([controller getCurrFileName]) { + x1 = kCurrFileTextXRatio; + + y1 = kFileTextYRatio; + + //note that we don't flip the Y cursor like we usually need to (but since this is a vertical line, it doesn't matter) + x1 = 2*x1-1.0; + y1 = y1*2 - 1.0; + StringTexture* activityString=[[StringTexture alloc] + initWithString: [controller getCurrFileName] + withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSColor blackColor],NSForegroundColorAttributeName, + [NSFont systemFontOfSize:12.0],NSFontAttributeName, + nil,NSParagraphStyleAttributeName,nil] + withTextColor:[NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.0f alpha:1.0f] + withBoxColor:[NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha: 0.0f] + withBorderColor:[NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha:0.0f]]; + + [self drawText:activityString atGLX:x1 atGLY:y1 atEnd:NO]; + [activityString release]; + } } + +//#define kVolumeButtonXRatio 0.05 +//#define kBackButtonXRatio 0.4 +//#define kForwardButtonXRatio 0.56 +//#define kButtonYRatio 0.02 - (void) mouseDown: (NSEvent *) event { NSPoint point = [event locationInWindow]; + float y1,y2,x1,x2; + x1 = kVolumeButtonXRatio * [renderBitmap pixelsWide]; + x2 = x1+volume25ImgInfo.width; + y1 = (1.0 - kButtonYRatio) * ([renderBitmap pixelsHigh] - volume25ImgInfo.height) ; // y is flipped for some reason. + y2 = y1+volume25ImgInfo.height; - if(point.x) { - +//NSLog([NSString stringWithFormat:@"click x1 %f x2 %f x %f y1 %f y2 %f y %f pixels high %i", x1, x2, point.x, y1, y2, point.y, [renderBitmap pixelsHigh]]); + if(point.x >= x1 && point.x < x2 && point.y>= y1 && point.y < y2) { + //volume click. + [controller changeVolume:self]; } } // mouseDown Added: NoiseMP3/backimg.png =================================================================== (Binary files differ) Property changes on: NoiseMP3/backimg.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: NoiseMP3/forwardimg.png =================================================================== (Binary files differ) Property changes on: NoiseMP3/forwardimg.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-20 01:39:20
|
Revision: 224 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=224&view=rev Author: mchinen Date: 2010-07-20 01:39:13 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Adding PlayerWindow to allow borderless windows via nib. Added Paths: ----------- NoiseMP3/PlayerWindow.h NoiseMP3/PlayerWindow.m Added: NoiseMP3/PlayerWindow.h =================================================================== --- NoiseMP3/PlayerWindow.h (rev 0) +++ NoiseMP3/PlayerWindow.h 2010-07-20 01:39:13 UTC (rev 224) @@ -0,0 +1,18 @@ +/* + * PlayerWindow.h + * NoiseMP3 + * + * Created by Administrator on 7/20/10. + * Copyright 2010 __MyCompanyName__. All rights reserved. + * + */ + + +#import <Cocoa/Cocoa.h> +@interface PlayerWindow : NSWindow { + +} + + +- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag; +@end \ No newline at end of file Added: NoiseMP3/PlayerWindow.m =================================================================== --- NoiseMP3/PlayerWindow.m (rev 0) +++ NoiseMP3/PlayerWindow.m 2010-07-20 01:39:13 UTC (rev 224) @@ -0,0 +1,21 @@ +// +// PlayerWindow.m +// NoiseMP3 +// +// Created by Administrator on 7/20/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "PlayerWindow.h" + +@implementation PlayerWindow +- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { + NSRect realRect; + realRect = contentRect; + realRect.size.width += contentRect.origin.x; + realRect.size.height += contentRect.origin.y; + realRect.origin.x = realRect.origin.y=0; + NSWindow *result = [super initWithContentRect:realRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + return result; +} +@end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-20 01:38:47
|
Revision: 223 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=223&view=rev Author: mchinen Date: 2010-07-20 01:38:40 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Adding Fullscreen button redrawing to come next. also contains a chirpsynth modification to handle foreign chars. Modified Paths: -------------- NoiseMP3/ChirpSynth.cpp NoiseMP3/English.lproj/MainMenu.nib/classes.nib NoiseMP3/English.lproj/MainMenu.nib/info.nib NoiseMP3/English.lproj/MainMenu.nib/keyedobjects.nib NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj NoiseMP3/PlayerController.h NoiseMP3/PlayerController.mm NoiseMP3/PlayerView.h NoiseMP3/PlayerView.m Modified: NoiseMP3/ChirpSynth.cpp =================================================================== --- NoiseMP3/ChirpSynth.cpp 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/ChirpSynth.cpp 2010-07-20 01:38:40 UTC (rev 223) @@ -70,8 +70,17 @@ //freq2 = 1.3*ch; // freq = 2000+200*(ch-'A'); // freq2 = 5000+50*(ch-'A'); + + //limit the char to 'A' to 'z' (for jp and other langs) + if(ch < 'A') + ch+='A'; + if(ch > 'z') + ch= (ch%('z'-'A'))+'A'; + freq = 1000+100*(ch-'A'); freq2 = 2500+25*(ch-'A'); + + //freq2 = 10.3*ch; //freq = 200.3*ch; Modified: NoiseMP3/English.lproj/MainMenu.nib/classes.nib =================================================================== --- NoiseMP3/English.lproj/MainMenu.nib/classes.nib 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/English.lproj/MainMenu.nib/classes.nib 2010-07-20 01:38:40 UTC (rev 223) @@ -11,6 +11,8 @@ <string>id</string> <key>chooseAudioFile</key> <string>id</string> + <key>launchFullScreen</key> + <string>id</string> <key>playPause</key> <string>id</string> </dict> @@ -34,6 +36,14 @@ </dict> <dict> <key>CLASS</key> + <string>PlayerWindow</string> + <key>LANGUAGE</key> + <string>ObjC</string> + <key>SUPERCLASS</key> + <string>NSWindow</string> + </dict> + <dict> + <key>CLASS</key> <string>FirstResponder</string> <key>LANGUAGE</key> <string>ObjC</string> Modified: NoiseMP3/English.lproj/MainMenu.nib/info.nib =================================================================== --- NoiseMP3/English.lproj/MainMenu.nib/info.nib 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/English.lproj/MainMenu.nib/info.nib 2010-07-20 01:38:40 UTC (rev 223) @@ -10,8 +10,8 @@ <integer>5</integer> <key>IBOpenObjects</key> <array> + <integer>209</integer> <integer>136</integer> - <integer>21</integer> </array> <key>IBSystem Version</key> <string>9L31a</string> Modified: NoiseMP3/English.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj =================================================================== --- NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/NoiseMP3.xcodeproj/project.pbxproj 2010-07-20 01:38:40 UTC (rev 223) @@ -41,6 +41,7 @@ 84EAAC0C11AF149700223A1C /* ChirpSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAAC0B11AF149700223A1C /* ChirpSynth.cpp */; }; 84EAACEC11AF267C00223A1C /* DelaySynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAACEB11AF267C00223A1C /* DelaySynth.cpp */; }; 84EAAF0D11B2FCE900223A1C /* DownsampleSynth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAAF0C11B2FCE900223A1C /* DownsampleSynth.cpp */; }; + 84FAF04411F52ADB00F842E2 /* PlayerWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FAF04311F52ADB00F842E2 /* PlayerWindow.m */; }; 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; @@ -116,6 +117,8 @@ 84EAACEB11AF267C00223A1C /* DelaySynth.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = DelaySynth.cpp; sourceTree = "<group>"; }; 84EAAF0B11B2FCE900223A1C /* DownsampleSynth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownsampleSynth.h; sourceTree = "<group>"; }; 84EAAF0C11B2FCE900223A1C /* DownsampleSynth.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = DownsampleSynth.cpp; sourceTree = "<group>"; }; + 84FAF03E11F52A5900F842E2 /* PlayerWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerWindow.h; sourceTree = "<group>"; }; + 84FAF04311F52ADB00F842E2 /* PlayerWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayerWindow.m; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D1107320486CEB800E47090 /* MiruTune.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MiruTune.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -159,6 +162,8 @@ 18CE3F8D1147EE8900282C50 /* CurrentAppData.mm */, 1851DED9116418A0001687A6 /* SongActivityList.h */, 1851DEDA116418A0001687A6 /* SongActivityList.m */, + 84FAF03E11F52A5900F842E2 /* PlayerWindow.h */, + 84FAF04311F52ADB00F842E2 /* PlayerWindow.m */, ); name = Classes; sourceTree = "<group>"; @@ -363,6 +368,7 @@ 84EAAC0C11AF149700223A1C /* ChirpSynth.cpp in Sources */, 84EAACEC11AF267C00223A1C /* DelaySynth.cpp in Sources */, 84EAAF0D11B2FCE900223A1C /* DownsampleSynth.cpp in Sources */, + 84FAF04411F52ADB00F842E2 /* PlayerWindow.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: NoiseMP3/PlayerController.h =================================================================== --- NoiseMP3/PlayerController.h 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/PlayerController.h 2010-07-20 01:38:40 UTC (rev 223) @@ -33,20 +33,19 @@ }; @interface PlayerController : NSObject { - IBOutlet NSTextField *fileNameField; - - IBOutlet NSButton *playButton; - IBOutlet NSButton *volumeButton; - - IBOutlet PlayerView *playerView; - - PlayerModel *playerModel; - int playerState; + IBOutlet NSTextField *fileNameField; + IBOutlet NSButton *playButton; + IBOutlet NSButton *volumeButton; + IBOutlet PlayerView *playerView; + + PlayerModel *playerModel; + int playerState; CFRunLoopTimerRef viewTimer; - CFAbsoluteTime timeStamp; - int volumeState; + NSWindow *origWindow; + NSWindow *fsWindow; + bool fullScreen; } - (id) init; - dealloc; @@ -68,4 +67,7 @@ - (float)getPlaybackCursor; - (void) loadAudioFile:(NSString*)fileName; //drag n drop +- (void)launchFullScreen:(id)sender; +- (void)revertNormalScreen; + @end Modified: NoiseMP3/PlayerController.mm =================================================================== --- NoiseMP3/PlayerController.mm 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/PlayerController.mm 2010-07-20 01:38:40 UTC (rev 223) @@ -17,8 +17,9 @@ { if ( (self = [super init]) != NULL) { - viewTimer=NULL; + viewTimer=NULL; playerModel = [[PlayerModel alloc] initWithPlayerController:self]; + fullScreen = NO; // [[NSWorkspace sharedWorkspace] activeApplication]; } return(self); @@ -33,6 +34,8 @@ [playButton setKeyEquivalent:@" "]; volumeState = eMedium; + + [[playerView window] makeFirstResponder:playerView]; [self changeVolume:self]; [self displayPausing]; [self startTimer]; @@ -168,6 +171,82 @@ } } +- (void)launchFullScreen:(id)sender +{ + if(fullScreen) + return; + fullScreen=YES; + + [playerView setFullScreen:YES]; +// +// +// int windowLevel; +// NSRect screenRect; +// // Capture the main display +// if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) { +// NSLog( @"Couldn't capture the main display!" ); +// // Note: you'll probably want to display a proper error dialog here +// } +// // Get the shielding window level +// windowLevel = CGShieldingWindowLevel(); +// +// // Get the screen rect of our main display +// screenRect = [[NSScreen mainScreen] frame]; +// +// origWindow = [playerView window]; +// // Put up a new window +// fsWindow = [[NSWindow alloc] initWithContentRect:screenRect +// styleMask:NSBorderlessWindowMask +// backing:NSBackingStoreBuffered //NSBackingStoreBuffered +// defer:NO screen:[NSScreen mainScreen]]; +// +// [fsWindow setLevel:windowLevel]; +// +// +// // [[MainView superview] addSubview:newMainView]; +// [fsWindow makeFirstResponder:playerView]; +// +// [fsWindow setBackgroundColor:[NSColor blackColor]]; +// [fsWindow makeKeyAndOrderFront:nil]; +// +// //get this to go up. +// [[playerView window] setFrame:screenRect display:YES]; +// [fsWindow setContentView:[[playerView window] contentView]]; +// +// NSOpenGLContext* context = [playerView openGLContext]; +// // set fullscreen: +// [context setFullScreen]; +} + +- (void)revertNormalScreen +{ + + if(!fullScreen) + return; + fullScreen=NO; + [playerView setFullScreen:NO]; + + // [fsWindow orderOut:self]; +// +// [origWindow setContentView:[[playerView window] contentView]]; +// [fsWindow release]; +// +// // Release the display(s) +// if (CGDisplayRelease( kCGDirectMainDisplay ) != kCGErrorSuccess) { +// NSLog( @"Couldn't release the display(s)!" ); +// // Note: if you display an error dialog here, make sure you set +// // its window level to the same one as the shield window level, +// // or the user won't see anything. +// } +// //[fsWindow orderOut:self]; +// // +// // [[playerView window] setContentView:[[playerView window] contentView]]; +// // +} + + + + @end Modified: NoiseMP3/PlayerView.h =================================================================== --- NoiseMP3/PlayerView.h 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/PlayerView.h 2010-07-20 01:38:40 UTC (rev 223) @@ -26,6 +26,9 @@ int lastDuration; int cyclehack; float lastCursor; + + bool fullScreen; + NSOpenGLContext* fullScreenOpenGLContext; } - (id)initWithFrame:(NSRect)frame; - dealloc ; @@ -54,4 +57,10 @@ //attributes (inc antialias) + (NSOpenGLPixelFormat*)defaultPixelFormat; ++ (NSOpenGLPixelFormat*)fullScreenPixelFormat; + +- (void)keyDown:(NSEvent *)event; +- (void)setFullScreen:(BOOL)inFullScreen; +- (void) mouseDown: (NSEvent *) event; + @end Modified: NoiseMP3/PlayerView.m =================================================================== --- NoiseMP3/PlayerView.m 2010-07-19 22:55:51 UTC (rev 222) +++ NoiseMP3/PlayerView.m 2010-07-20 01:38:40 UTC (rev 223) @@ -15,13 +15,13 @@ #include <CoreFoundation/CFTimeZone.h> #include <OpenGL/gl.h> #include <GLUT/glut.h> +#include <unistd.h> @implementation PlayerView + (NSOpenGLPixelFormat*)defaultPixelFormat { - NSOpenGLPixelFormatAttribute attributes [] = { // 1 NSOpenGLPFAWindow, NSOpenGLPFADoubleBuffer, @@ -39,6 +39,20 @@ } ++ (NSOpenGLPixelFormat*)fullScreenPixelFormat +{ + + NSOpenGLPixelFormatAttribute attributes [] = { // 1 + // NSOpenGLPFAWindow, + NSOpenGLPFAFullScreen , + (NSOpenGLPixelFormatAttribute)nil + }; + + return [[NSOpenGLPixelFormat alloc] + initWithAttributes:attributes] ; +} + + - (id)initWithFrame:(NSRect)frame { NSOpenGLPixelFormat* format = [PlayerView defaultPixelFormat] ; self = [super initWithFrame:frame @@ -48,7 +62,7 @@ [[self openGLContext] makeCurrentContext]; glEnable (GL_MULTISAMPLE_ARB); glHint (GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); - + fullScreen=NO; cyclehack =0; lastCursor=0.0; @@ -194,6 +208,9 @@ - (void)drawRect:(NSRect)rect { +if (fullScreen) + [fullScreenOpenGLContext makeCurrentContext]; + // [NSGraphicsContext saveGraphicsState]; // NSGraphicsContext* context = [NSGraphicsContext currentContext]; @@ -247,7 +264,19 @@ // [NSGraphicsContext restoreGraphicsState]; glFinish(); - [[self openGLContext] flushBuffer]; + // Flush and restore context if necessary + + if (fullScreen) + { + [fullScreenOpenGLContext flushBuffer]; + [[self openGLContext] makeCurrentContext]; + } + else + { + + [[self openGLContext] flushBuffer]; + } + } //number of x pixels after right side bar of duration text e.g. (4'36") #define kDurationTextXOffset -6 @@ -754,11 +783,8 @@ [self createAndDrawActivityText:activity x:textX y:textY grayText:NO]; //finally draw a line for the cursor on the bar. [self drawCursor:cursor lineWidth:1.0 isBlack:cursor]; - - //save the x so that we don't overwrite it with the main playhead lastBlackCursorX=cursorX; - } -(void) drawPlayBarBackground @@ -790,4 +816,232 @@ } +#define kPlayButtonXRatio 0.5 +#define kPlayButtonYRatio 0.08 +-(void) drawPlayPauseButton { + +// glBegin(GL_POLYGON); +// +// glColor4f(0.0,0.0,0.0,1.0); +// glVertex2f(0, y2); +// glVertex2f(x2, y1); +// glVertex2f(x1, y1); +// glVertex2f(x1, y2); +// +// glEnd(); +} + +- (void) mouseDown: (NSEvent *) event +{ + NSPoint point = [event locationInWindow]; + + if(point.x) { + + } + +} // mouseDown + +// Keyboard handling + +- (void)keyDown:(NSEvent *)event { +/* + NSString *keys = [event charactersIgnoringModifiers]; + wormHeading = kGameHeadingStraight; + if (keys && [keys length] > 0) { + unichar c = [keys characterAtIndex:0]; + if (c == NSLeftArrowFunctionKey) { + wormHeading = kGameHeadingLeft; + } else if (c == NSRightArrowFunctionKey) { + wormHeading = kGameHeadingRight; + } + } + + apple's bullshit hides this list. + +"0x31" = "Space"; +"0x24" = "Return"; +"0x30" = "Tab"; +"0x33" = "Backspace"; +"0x35" = "Escape"; + +"0x7A" = "F1"; +"0x78" = "F2"; +"0x63" = "F3"; +"0x76" = "F4"; +"0x60" = "F5"; +"0x61" = "F6"; +"0x62" = "F7"; +"0x64" = "F8"; +"0x65" = "F9"; +"0x6D" = "F10"; +"0x67" = "F11"; +"0x6F" = "F12"; +"0x69" = "F13"; +"0x6B" = "F14"; +"0x71" = "F15"; + +"0x7B" = "Left Arrow"; +"0x7D" = "Down Arrow"; +"0x7C" = "Right Arrow"; +"0x7E" = "Up Arrow"; + +"0x72" = "Help"; +"0x75" = "Delete"; +"0x73" = "Home"; +"0x77" = "End"; +"0x74" = "Page Up"; +"0x79" = "Page Down"; + +"0x52" = "Keypad 0"; +"0x41" = "Keypad ."; +"0x4C" = "Keypad Enter"; +"0x53" = "Keypad 1"; +"0x54" = "Keypad 2"; +"0x55" = "Keypad 3"; +"0x56" = "Keypad 4"; +"0x57" = "Keypad 5"; +"0x58" = "Keypad 6"; +"0x45" = "Keypad +"; +"0x59" = "Keypad 7"; +"0x5B" = "Keypad 8"; +"0x5C" = "Keypad 9"; +"0x4E" = "Keypad -"; +"0x47" = "Keypad Clear"; +"0x51" = "Keypad ="; +"0x4B" = "Keypad /"; +"0x43" = "Keypad *"; + +"0x0A" = "Mystery Key"; + +"0x36" = "Control"; +"0x3A" = "Option"; +"0x37" = "Command"; +"0x38" = "Shift"; +"0x39" = "Caps Lock"; + +*/ + // I added these based on the addition to your question :) + switch( [event keyCode] ) { + + + case 0x7A: //f1 + [controller launchFullScreen:self]; + break; + case 0x78: //f2 + [controller revertNormalScreen]; + break; + + case 126: // up arrow + break; + + case 125: // down arrow + break; + case 124: // right arrow + break; + case 123: // left arrow + break; + default: + NSLog(@"Key pressed: %@", event); + break; + } +} + + +- (void)setFullScreen:(BOOL)inFullScreen +{ + fullScreen = inFullScreen; + + if (inFullScreen) + { + if (!CGDisplayIsCaptured(kCGDirectMainDisplay)) + { + // Store the user’s ColorSync settings as the starting gamma values + + CGGammaValue + redMin, redMax, redGamma, + greenMin, greenMax, greenGamma, + blueMin, blueMax, blueGamma; + + CGGetDisplayTransferByFormula( + kCGDirectMainDisplay, + &redMin, &redMax, &redGamma, + &greenMin, &greenMax, &greenGamma, + &blueMin, &blueMax, &blueGamma + ); + + // Fade from current gamma (1.0) to black (0.0) + double theFadeValue ; + for (theFadeValue= 1.0; theFadeValue >= 0.0; theFadeValue -= 0.01) + { + CGSetDisplayTransferByFormula( + kCGDirectMainDisplay, + redMin, theFadeValue * redMax, redGamma, + greenMin, theFadeValue * greenMax, greenGamma, + blueMin, theFadeValue * blueMax, blueGamma + ); + // Sleep for 10ms + usleep(1000); + } + + CGDisplayCapture(kCGDirectMainDisplay); + CGDisplayHideCursor(kCGDirectMainDisplay); + + // Create a context for the full screen + + fullScreenOpenGLContext = [[NSOpenGLContext alloc] + initWithFormat:[PlayerView fullScreenPixelFormat] shareContext:[self openGLContext]]; + + long theOpenGLCPSwapInterval = 1; + [fullScreenOpenGLContext + setValues:(const long*) &theOpenGLCPSwapInterval + forParameter:(NSOpenGLContextParameter) NSOpenGLCPSwapInterval + ]; // Prevent tearing + + // Replace our fullScreen's existing context with this new one. + + [fullScreenOpenGLContext copyAttributesFromContext:[self openGLContext] withMask:GL_ALL_ATTRIB_BITS]; + [fullScreenOpenGLContext setFullScreen]; + [fullScreenOpenGLContext makeCurrentContext]; + + [self display]; + + // Fade from black back to original gamma + for (theFadeValue = 0.0; theFadeValue <= 1.0; theFadeValue += 0.01 ) + { + CGSetDisplayTransferByFormula( + kCGDirectMainDisplay, + redMin, theFadeValue * redMax, redGamma, + greenMin, theFadeValue * greenMax, greenGamma, + blueMin, theFadeValue * blueMax, blueGamma + ); + // Sleep for 10ms + usleep(1000); + } + + // Restore the user’s ColorSync settings + // (I don't really understand why the above doesn't properly restore + // the gamma, but the following call does make a difference). + + // CGDisplayRestoreColorSyncSettings(); + } + } + else + { + if (CGDisplayIsCaptured(kCGDirectMainDisplay)) + { + // Exit full screen mode + [fullScreenOpenGLContext clearDrawable]; + [NSOpenGLContext clearCurrentContext]; + [fullScreenOpenGLContext release]; + fullScreenOpenGLContext = 0; + + [self display]; + + CGDisplayShowCursor(kCGDirectMainDisplay); + CGDisplayRelease(kCGDirectMainDisplay); + } + } +} + + @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-19 22:55:58
|
Revision: 222 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=222&view=rev Author: mchinen Date: 2010-07-19 22:55:51 +0000 (Mon, 19 Jul 2010) Log Message: ----------- making fullscreen smoother Modified Paths: -------------- deadlock/English.lproj/MainNibFile.nib/info.nib deadlock/English.lproj/MainNibFile.nib/keyedobjects.nib deadlock/MainController.h deadlock/MainController.mm deadlock/MainView.m Modified: deadlock/English.lproj/MainNibFile.nib/info.nib =================================================================== --- deadlock/English.lproj/MainNibFile.nib/info.nib 2010-07-11 15:39:25 UTC (rev 221) +++ deadlock/English.lproj/MainNibFile.nib/info.nib 2010-07-19 22:55:51 UTC (rev 222) @@ -10,16 +10,16 @@ <string>100 498 254 44 0 0 1280 778 </string> </dict> <key>IBFramework Version</key> - <string>446.1</string> + <string>489.0</string> <key>IBOldestOS</key> <integer>4</integer> <key>IBOpenObjects</key> <array> <integer>21</integer> + <integer>313</integer> <integer>284</integer> - <integer>313</integer> </array> <key>IBSystem Version</key> - <string>8S2167</string> + <string>8S165</string> </dict> </plist> Modified: deadlock/English.lproj/MainNibFile.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: deadlock/MainController.h =================================================================== --- deadlock/MainController.h 2010-07-11 15:39:25 UTC (rev 221) +++ deadlock/MainController.h 2010-07-19 22:55:51 UTC (rev 222) @@ -31,6 +31,8 @@ FishBait* currentBait; + NSWindow *origWindow; + NSWindow *mainWindow; BOOL fullScreen; Modified: deadlock/MainController.mm =================================================================== --- deadlock/MainController.mm 2010-07-11 15:39:25 UTC (rev 221) +++ deadlock/MainController.mm 2010-07-19 22:55:51 UTC (rev 222) @@ -174,7 +174,8 @@ // Get the screen rect of our main display screenRect = [[NSScreen mainScreen] frame]; - // Put up a new window + origWindow = [mainView window]; + // Put up a new window mainWindow = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered @@ -207,7 +208,8 @@ [mainWindow orderOut:self]; - // [[mainView window] setContentView:[[mainView window] contentView]]; + [origWindow setContentView:[[mainView window] contentView]]; + [mainWindow release]; // Release the display(s) if (CGDisplayRelease( kCGDirectMainDisplay ) != kCGErrorSuccess) { @@ -216,6 +218,10 @@ // its window level to the same one as the shield window level, // or the user won't see anything. } + //[mainWindow orderOut:self]; +// +// [[mainView window] setContentView:[[mainView window] contentView]]; +// } Modified: deadlock/MainView.m =================================================================== --- deadlock/MainView.m 2010-07-11 15:39:25 UTC (rev 221) +++ deadlock/MainView.m 2010-07-19 22:55:51 UTC (rev 222) @@ -64,7 +64,7 @@ backgroundColor =[NSColor blackColor];// [[NSColor colorWithPatternImage:[NSImage imageNamed:@"Background Pattern"]] copy]; [self setString:NSLocalizedString(@"Default Worm String", "The string to be used for the worm's body")]; [self setInitialLength:DEFAULT_LENGTH]; - [self setDesiredFrameRate:100.0]; + [self setDesiredFrameRate:30.0]; [self reset]; lastUpdateTime = [NSDate timeIntervalSinceReferenceDate]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-11 15:39:31
|
Revision: 221 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=221&view=rev Author: mchinen Date: 2010-07-11 15:39:25 +0000 (Sun, 11 Jul 2010) Log Message: ----------- add colors to bar animation Modified Paths: -------------- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-07-10 00:02:29 UTC (rev 220) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-07-11 15:39:25 UTC (rev 221) @@ -77,6 +77,8 @@ m_seed = time(NULL); stime = (unsigned) m_seed/2; srand(stime); + + m_arrayStatus = NULL; // stringLock = [[NSLock alloc] init]; m_looping=false; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h 2010-07-10 00:02:29 UTC (rev 220) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h 2010-07-11 15:39:25 UTC (rev 221) @@ -61,8 +61,8 @@ int GetArraySize() {return m_size;} double* GetArray() {return m_lastSort.array; } - - + int* GetArrayStatus(){return m_arrayStatus; } + void SetArrayStatus(int* status){m_arrayStatus = status;} protected: //private constructor - Singleton. SortingMan(); @@ -73,6 +73,8 @@ bool m_inited; bool m_looping; + int* m_arrayStatus; + //random seed - used to generate duplicates etc long m_seed; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp 2010-07-10 00:02:29 UTC (rev 220) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp 2010-07-11 15:39:25 UTC (rev 221) @@ -6,7 +6,7 @@ #include "SortingMan.h" - +static int *arrayStatus = NULL; static double doublePair[2]; void printdoublearray(double* array, int size, int focusstart, int focussize, int swapaindex, int swapbindex){ int i; @@ -24,12 +24,15 @@ { lastSize = size; last = new double[size]; + arrayStatus = new int[size]; } else if(lastSize!=size) { delete [] last; + delete [] arrayStatus; lastSize = size; last = new double[size]; + arrayStatus = new int[size]; } else { @@ -56,15 +59,21 @@ { bool changed; changed = false; + arrayStatus[i] = 0; //see if the value changed from last array if(haveLast) { - if(last[i]!=array[i]) + if(last[i]!=array[i]){ + arrayStatus[i] = 1; changed= true; + } } //save last[i] = array[i]; sprintf(myString," %4.0f",array[i]); + if(!arrayStatus[i]) { + arrayStatus[i] = (i==swapaindex||i==swapbindex) ? 2:(i>=focusstart && i < focusstart+focussize)?3:0; + } // myString = [[NSAttributedString alloc] // initWithString:[NSString stringWithFormat:@" %4.0f",array[i]] // attributes: changed?redAttrs: @@ -74,6 +83,7 @@ SortingMan::Instance()->AppendToOutput(myString); // [myString autorelease]; } + SortingMan::Instance()->SetArrayStatus(arrayStatus); sprintf(myString,"\n"); // myString = [[NSAttributedString alloc] Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-10 00:02:29 UTC (rev 220) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-11 15:39:25 UTC (rev 221) @@ -311,9 +311,30 @@ //the values change and there's a chance of corruption, but probably it won't happen and we can take a glitch. int len = SortingMan::Instance()->GetArraySize(); double* array = SortingMan::Instance()->GetArray(); + int* status = SortingMan::Instance()->GetArrayStatus(); float y1,y2; for(int i=0;i<len;i++){ - ofSetColor(0x666666); + if(status){ + switch(status[i]){ + //no change or focus or compare + case 0: + ofSetColor(0x333333); + break; + //change + case 1: + ofSetColor(0xFF6666); + break; + //compare + case 2: + ofSetColor(0x6666FF); + break; + //focus + case 3: + ofSetColor(0x66FF66); + break; + } + }else + ofSetColor(0x666666); y1 = ofGetHeight()/2; y2 = (1.0 + (array[i]/-100.0)) * ofGetHeight()/2; ofRect(ofGetWidth()*((float)i/len), mymin(y1,y2), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-10 00:02:37
|
Revision: 220 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=220&view=rev Author: mchinen Date: 2010-07-10 00:02:29 +0000 (Sat, 10 Jul 2010) Log Message: ----------- add how to build instructions Added Paths: ----------- algorhythmicSorting/ofAlgorhythmicSorting/howtobuild.txt Removed Paths: ------------- algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch Added: algorhythmicSorting/ofAlgorhythmicSorting/howtobuild.txt =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/howtobuild.txt (rev 0) +++ algorhythmicSorting/ofAlgorhythmicSorting/howtobuild.txt 2010-07-10 00:02:29 UTC (rev 220) @@ -0,0 +1,15 @@ +How to build ofAlgorithmicSorting +July 9 2010 +mchinen + +My directory structure is that I have a folder called svncheckouts in my home directory. + +Steps to build: +1.You need to have git installed and place a git clone of my ofxMSA addons at ../../../ofxMSA relative to this directory. +For me that means I type "cd ~/svncheckouts; ls" and I can see ofxMSA there. +1.1. install git if you don't have it with "sudo apt-get install git" or "sudo fink install git" +1.2. cd to the correct directory (for me "cd ~/svncheckouts") +1.3. type "git clone git://github.com/mchinen/ofxMSA.git" + +2.You need to have of installed to a directory that is ../../../../of/of_preRelease_v0061_osx_FAT (relative to this directory) + Deleted: algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt 2010-07-09 23:50:22 UTC (rev 219) +++ algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt 2010-07-10 00:02:29 UTC (rev 220) @@ -1,10 +0,0 @@ -To build this project you'll have to patch open frameworks' simpleguitoo add on to get things we use such as combo boxes. - -0.If you have applied previous patches you'll have to delete the contents of ofxSimpleGuiToo and do an svn update there to get it fresh (so the patch can be applied.) - -1.cd to the open frameworks gui add on directory: -cd ~/of/of_preRelease_v0061_osx_FAT/addons/ofxSimpleGuiToo -2.apply the patch -patch -p0 < ~/svncheckouts/algorhythmics/algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch - -Then build and run. Deleted: algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch 2010-07-09 23:50:22 UTC (rev 219) +++ algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch 2010-07-10 00:02:29 UTC (rev 220) @@ -1,374 +0,0 @@ -Index: src/ofxSimpleGuiConfig.cpp -=================================================================== ---- src/ofxSimpleGuiConfig.cpp (revision 204) -+++ src/ofxSimpleGuiConfig.cpp (working copy) -@@ -47,6 +47,7 @@ - toggleHeight = titleHeight; - buttonHeight = titleHeight; - slider2DTextHeight = titleHeight * 1.5; -+ comboBoxHeight = 15; - - - padding.set (titleHeight/2, 10); -Index: src/Controls/ofxSimpleGuiComboBox.cpp -=================================================================== ---- src/Controls/ofxSimpleGuiComboBox.cpp (revision 0) -+++ src/Controls/ofxSimpleGuiComboBox.cpp (revision 0) -@@ -0,0 +1,163 @@ -+/* -+ * ofxSimpleGuiComboBox.cpp -+ * AlgorhythmicSorting -+ * -+ * Created by Administrator on 7/2/10. -+ * Copyright 2010 __MyCompanyName__. All rights reserved. -+ * -+ */ -+ -+#include "ofxSimpleGuiComboBox.h" -+#include "ofxSimpleGuiPage.h" -+ -+ofxSimpleGuiComboBox::ofxSimpleGuiComboBox(string name, int &choice_out, int numChoices, ofxSimpleGuiPage *owner, const char** choiceTitles ) : -+ofxSimpleGuiControl(name), -+m_selectedChoice(choice_out), -+m_page(owner) { -+ m_selectedChoice = m_mouseChoice = 0; -+ if(numChoices <=1) -+ numChoices = 1; -+ m_numChoices = numChoices; -+ m_hasFocus=false; -+ beenPressed = false; -+ char* titlestring; -+ -+ for(int i=0;i<numChoices;i++){ -+ titlestring = (char*)malloc(choiceTitles?strlen(choiceTitles[i]):10); -+ if(choiceTitles) -+ strcpy(titlestring,choiceTitles[i]); -+ else { -+ strcpy(titlestring,"1"); -+ titlestring[0]+=i; //only valid for 9 entries -+ } -+ m_choiceTitles.push_back(titlestring); -+// free(titlestring); -+ } -+ controlType = "ComboBox"; -+ setup(); -+} -+ -+ofxSimpleGuiComboBox::~ofxSimpleGuiComboBox() { -+ //kill the strings -+ for(int i =0;i<m_numChoices;i++) { -+ free(m_choiceTitles[i]); -+ } -+} -+ -+void ofxSimpleGuiComboBox::SetTitle(int index, const char* title) { -+ //we don't check null and index bounds. -+ free(m_choiceTitles[index]); -+ char* titlestring = (char*)malloc(strlen(title)); -+ strcpy(titlestring, title); -+ m_choiceTitles[index]=titlestring; -+} -+ -+void ofxSimpleGuiComboBox::setup() { -+ setSize(config->gridSize.x - config->padding.x, config->comboBoxHeight); -+} -+ -+void ofxSimpleGuiComboBox::loadFromXML(ofxXmlSettings &XML) { -+//TODO: -+// set(XML.getValue("controls:" + controlType + "_" + key + ":value", 0)); -+} -+ -+void ofxSimpleGuiComboBox::saveToXML(ofxXmlSettings &XML) { -+//TODO: -+ XML.addTag(controlType + "_" + key); -+ XML.pushTag(controlType + "_" + key); -+ XML.addValue("name", name); -+// XML.addValue("value", getValue()); -+ XML.popTag(); -+} -+ -+void ofxSimpleGuiComboBox::keyPressed( int key ) { -+//TODO do up/down -+// if(key==keyboardShortcut) toggle(); -+} -+ -+int ofxSimpleGuiComboBox::getChoice() { -+ return m_selectedChoice; -+} -+ -+//press was outside - handle. -+void onPressOutside(int x, int y, int button) { -+ -+} -+ -+void ofxSimpleGuiComboBox::onPress(int x, int y, int button) { -+ beenPressed = true; -+ -+ //a click toggles focus state if we are off -+ if(!m_hasFocus) { -+ //expand the height for all choices -+ setSize(config->gridSize.x - config->padding.x, config->comboBoxHeight * m_numChoices); -+ m_hasFocus = true; -+ //notify that we want to steal all events from the page -+ m_page->SetEventStealingControl(*this); -+ } -+} -+ -+void ofxSimpleGuiComboBox::onPressOutside(int x, int y, int button){ -+ -+} -+ -+ -+void ofxSimpleGuiComboBox::onDragOver(int x, int y, int button){ -+ //same behavior as mouse move -+ onMouseMove(x,y); -+} -+ -+void ofxSimpleGuiComboBox::onMouseMove(int x, int y) { -+ if(m_hasFocus) { -+ //see which index was selected. -+ m_mouseChoice = (y-this->y)/config->comboBoxHeight; -+ //TODO:replace with OF constrain macro. -+ m_mouseChoice = m_mouseChoice < 0?0:(m_mouseChoice>= m_numChoices? m_numChoices-1:m_mouseChoice); -+ } -+} -+ -+void ofxSimpleGuiComboBox::onRelease(int x, int y, int button) { -+ if(m_hasFocus) { -+ //see which index was selected, but only if the user actually moved around. -+ m_selectedChoice = m_mouseChoice >= 0? m_mouseChoice : m_selectedChoice; -+ -+ //a release toggles focus state if we are on - TODO: unless x and y don't change -+ m_hasFocus = false; -+ setSize(config->gridSize.x - config->padding.x, config->comboBoxHeight); -+ //also let the page know we don't need to steal all the events and draw over anymore -+ m_page->ReleaseEventStealingControl(); -+ -+ } -+} -+ -+void ofxSimpleGuiComboBox::draw(float x, float y) { -+ setPos(x, y); -+ -+ glPushMatrix(); -+ glTranslatef(x, y, 0); -+ -+ ofEnableAlphaBlending(); -+ ofFill(); -+ setTextBGColor(); -+ ofRect(0, 0, width, height); -+ -+ setTextColor(); -+ if(!m_hasFocus) -+ ofDrawBitmapString(m_choiceTitles[m_selectedChoice], 3, 10);//15); -+ else { -+ for(int i=0; i < m_numChoices; i++) { -+ setTextColor(); -+ //invert for selected choice -+ if(i==m_mouseChoice){ -+ //draw a text colored rect so we can see the inverse -+ ofRect(0, i*config->comboBoxHeight, width, config->comboBoxHeight); -+ setTextBGColor(); -+ } -+ -+ ofDrawBitmapString(m_choiceTitles[i], 3, config->comboBoxHeight * i + 10);//15); -+ } -+ } -+ ofDisableAlphaBlending(); -+ -+ glPopMatrix(); -+} -Index: src/Controls/ofxSimpleGuiComboBox.h -=================================================================== ---- src/Controls/ofxSimpleGuiComboBox.h (revision 0) -+++ src/Controls/ofxSimpleGuiComboBox.h (revision 0) -@@ -0,0 +1,43 @@ -+/* -+ * ofxSimpleGuiComboBox.h -+ * open frameworks simpleguitoo -+ * -+ * Created by Michael Chinen on 7/2/10. -+ * -+ */ -+ -+#pragma once -+ -+#include "ofxSimpleGuiControl.h" -+ -+ -+class ofxSimpleGuiPage; -+class ofxSimpleGuiComboBox : public ofxSimpleGuiControl { -+public: -+ -+ ofxSimpleGuiComboBox(string name, int &choice_out, int numChoices, ofxSimpleGuiPage *owner, const char** choiceTitles = NULL ) ; -+ virtual ~ofxSimpleGuiComboBox(); -+ -+ void setup(); -+ void loadFromXML(ofxXmlSettings &XML); -+ void saveToXML(ofxXmlSettings &XML); -+ void keyPressed( int key ); -+ -+ int getChoice(); -+ void onPress(int x, int y, int button); -+ void onRelease(int x, int y, int button); -+ void draw(float x, float y); -+ -+ void SetTitle(int index, const char* title); -+ virtual void onPressOutside(int x, int y, int button); -+ virtual void onMouseMove(int x, int y); -+ virtual void onDragOver(int x, int y, int button); -+protected: -+ int m_mouseChoice; -+ int &m_selectedChoice; -+ int m_numChoices; -+ bool m_hasFocus; -+ vector<char*> m_choiceTitles; -+ ofxSimpleGuiPage* m_page; -+ bool beenPressed; -+}; -Index: src/ofxSimpleGuiToo.h -=================================================================== ---- src/ofxSimpleGuiToo.h (revision 204) -+++ src/ofxSimpleGuiToo.h (working copy) -@@ -98,7 +98,7 @@ - ofxSimpleGuiTitle &addTitle(string name="", float height = 0); - ofxSimpleGuiToggle &addToggle(string name, bool &value); - ofxSimpleGuiColorPicker &addColorPicker(string name, float *values); -- -+ ofxSimpleGuiComboBox &addComboBox(string name, int &choice_out, int numChoices,const char** choiceTitles=NULL); - void draw(); - - -Index: src/ofxSimpleGuiConfig.h -=================================================================== ---- src/ofxSimpleGuiConfig.h (revision 204) -+++ src/ofxSimpleGuiConfig.h (working copy) -@@ -48,6 +48,7 @@ - float sliderTextHeight; - float slider2DTextHeight; - float titleHeight; -+ float comboBoxHeight; - - ofPoint padding; - ofPoint offset; -Index: src/ofxSimpleGuiIncludes.h -=================================================================== ---- src/ofxSimpleGuiIncludes.h (revision 204) -+++ src/ofxSimpleGuiIncludes.h (working copy) -@@ -47,5 +47,6 @@ - #include "ofxSimpleGuiToggle.h" - #include "ofxSimpleGuiTitle.h" - #include "ofxSimpleGuiColorPicker.h" -+#include "ofxSimpleGuiComboBox.h" - //#include "ofxSimpleGuiOption.h" - //#include "ofxSimpleGuiOptionGroup.h" -Index: src/ofxSimpleGuiPage.cpp -=================================================================== ---- src/ofxSimpleGuiPage.cpp (revision 204) -+++ src/ofxSimpleGuiPage.cpp (working copy) -@@ -40,6 +40,7 @@ - disableAllEvents(); - width = 0; - height = ofGetHeight(); -+ eventStealingControl = NULL; - setXMLName(name + "_settings.xml"); - } - -@@ -202,26 +203,41 @@ - } - - -+ofxSimpleGuiComboBox &ofxSimpleGuiPage::addComboBox(string name, int &choice_out, int numChoices,const char** choiceTitles) { -+ return (ofxSimpleGuiComboBox &)addControl(* new ofxSimpleGuiComboBox(name, choice_out, numChoices, this, choiceTitles)); -+} - - -+ -+ - void ofxSimpleGuiPage::update(ofEventArgs &e) { - for(int i=0; i<controls.size(); i++) controls[i]->update(); - } - - - void ofxSimpleGuiPage::mouseMoved(ofMouseEventArgs &e) { -- for(int i=0; i<controls.size(); i++) controls[i]->_mouseMoved(e); -+ if(eventStealingControl) -+ eventStealingControl->_mouseMoved(e); -+ else -+ for(int i=0; i<controls.size(); i++) controls[i]->_mouseMoved(e); - } - - void ofxSimpleGuiPage::mousePressed(ofMouseEventArgs &e) { -+ if(eventStealingControl) -+ eventStealingControl->_mousePressed(e); -+ else - for(int i=0; i<controls.size(); i++) controls[i]->_mousePressed(e); - } - - void ofxSimpleGuiPage::mouseDragged(ofMouseEventArgs &e) { -+ if(eventStealingControl) -+ eventStealingControl->_mouseDragged(e); - for(int i=0; i<controls.size(); i++) controls[i]->_mouseDragged(e); - } - - void ofxSimpleGuiPage::mouseReleased(ofMouseEventArgs &e) { -+ if(eventStealingControl) -+ eventStealingControl->_mouseReleased(e); - for(int i=0; i<controls.size(); i++) controls[i]->_mouseReleased(e); - } - -@@ -233,3 +249,11 @@ - for(int i=0; i<controls.size(); i++) controls[i]->_keyReleased(e); - } - -+void ofxSimpleGuiPage::SetEventStealingControl(ofxSimpleGuiControl &control) { -+ eventStealingControl = &control; -+} -+void ofxSimpleGuiPage::ReleaseEventStealingControl() { -+ eventStealingControl = NULL; -+} -+ -+ -Index: src/ofxSimpleGuiToo.cpp -=================================================================== ---- src/ofxSimpleGuiToo.cpp (revision 204) -+++ src/ofxSimpleGuiToo.cpp (working copy) -@@ -321,7 +321,12 @@ - } - - -+ofxSimpleGuiComboBox &ofxSimpleGuiToo::addComboBox(string name, int &choice_out, int numChoices,const char** choiceTitles) { -+ if(!config) setup(); -+ return pages[currentPage]->addComboBox(name, choice_out, numChoices, choiceTitles); -+} - -+ - //void ofxSimpleGuiToo::setup(ofEventArgs &e) { - void ofxSimpleGuiToo::update(ofEventArgs &e) { - if(changePage) { -Index: src/ofxSimpleGuiPage.h -=================================================================== ---- src/ofxSimpleGuiPage.h (revision 204) -+++ src/ofxSimpleGuiPage.h (working copy) -@@ -65,8 +65,11 @@ - ofxSimpleGuiTitle &addTitle(string name="", float height = 0); - ofxSimpleGuiToggle &addToggle(string name, bool &value); - ofxSimpleGuiColorPicker &addColorPicker(string name, float *values); -+ ofxSimpleGuiComboBox &addComboBox(string name, int &choice_out, int numChoices, const char** choiceTitles=NULL); - -- -+ void SetEventStealingControl(ofxSimpleGuiControl &control); -+ void ReleaseEventStealingControl(); -+ - // void setup(ofEventArgs &e); - void update(ofEventArgs &e); - // void draw(ofEventArgs &e); -@@ -82,6 +85,8 @@ - - protected: - vector <ofxSimpleGuiControl*> controls; -+ //some controls can take over focus (e.g. combo box,) which means events should only be passed to them -+ ofxSimpleGuiControl* eventStealingControl; - float getNextY(float y); - ofxXmlSettings XML; - string xmlFilename; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-09 23:50:29
|
Revision: 219 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=219&view=rev Author: mchinen Date: 2010-07-09 23:50:22 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Add combo box and bar-line drawing. Modified Paths: -------------- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h Added Paths: ----------- algorhythmicSorting/ofAlgorhythmicSorting/bin/ algorhythmicSorting/ofAlgorhythmicSorting/bin/data/ algorhythmicSorting/ofAlgorhythmicSorting/bin/data/Courier New.ttf Modified: algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-07-02 15:24:58 UTC (rev 218) +++ algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-07-09 23:50:22 UTC (rev 219) @@ -7,26 +7,27 @@ objects = { /* Begin PBXBuildFile section */ + 840F2C9511E7869C00C5CD20 /* ofxMSAInteractiveObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2C9311E7869C00C5CD20 /* ofxMSAInteractiveObject.cpp */; }; + 840F2CF211E788F300C5CD20 /* ofxSimpleGuiButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CCC11E788F200C5CD20 /* ofxSimpleGuiButton.cpp */; }; + 840F2CF311E788F300C5CD20 /* ofxSimpleGuiColorPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CCE11E788F200C5CD20 /* ofxSimpleGuiColorPicker.cpp */; }; + 840F2CF411E788F300C5CD20 /* ofxSimpleGuiComboBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CD011E788F200C5CD20 /* ofxSimpleGuiComboBox.cpp */; }; + 840F2CF511E788F300C5CD20 /* ofxSimpleGuiContent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CD211E788F200C5CD20 /* ofxSimpleGuiContent.cpp */; }; + 840F2CF611E788F300C5CD20 /* ofxSimpleGuiFPSCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CD411E788F200C5CD20 /* ofxSimpleGuiFPSCounter.cpp */; }; + 840F2CF711E788F300C5CD20 /* ofxSimpleGuiMovieSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CD611E788F200C5CD20 /* ofxSimpleGuiMovieSlider.cpp */; }; + 840F2CF811E788F300C5CD20 /* ofxSimpleGuiOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CD811E788F200C5CD20 /* ofxSimpleGuiOption.cpp */; }; + 840F2CF911E788F300C5CD20 /* ofxSimpleGuiOptionGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CDA11E788F200C5CD20 /* ofxSimpleGuiOptionGroup.cpp */; }; + 840F2CFA11E788F300C5CD20 /* ofxSimpleGuiQuadWarp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CDC11E788F200C5CD20 /* ofxSimpleGuiQuadWarp.cpp */; }; + 840F2CFB11E788F300C5CD20 /* ofxSimpleGuiSlider2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CDE11E788F200C5CD20 /* ofxSimpleGuiSlider2d.cpp */; }; + 840F2CFC11E788F300C5CD20 /* ofxSimpleGuiTitle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CE311E788F300C5CD20 /* ofxSimpleGuiTitle.cpp */; }; + 840F2CFD11E788F300C5CD20 /* ofxSimpleGuiToggle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CE511E788F300C5CD20 /* ofxSimpleGuiToggle.cpp */; }; + 840F2CFE11E788F300C5CD20 /* ofxSimpleGuiConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CE711E788F300C5CD20 /* ofxSimpleGuiConfig.cpp */; }; + 840F2CFF11E788F300C5CD20 /* ofxSimpleGuiControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CE911E788F300C5CD20 /* ofxSimpleGuiControl.cpp */; }; + 840F2D0011E788F300C5CD20 /* ofxSimpleGuiPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CEC11E788F300C5CD20 /* ofxSimpleGuiPage.cpp */; }; + 840F2D0111E788F300C5CD20 /* ofxSimpleGuiToo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2CEF11E788F300C5CD20 /* ofxSimpleGuiToo.cpp */; }; + 840F2DF911E7B63300C5CD20 /* ofxSimpleGuiTextInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840F2DF811E7B63300C5CD20 /* ofxSimpleGuiTextInput.cpp */; }; 8416E04411DA9FBA003A3B23 /* openFrameworks.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8416E04311DA9FBA003A3B23 /* openFrameworks.a */; }; 8416E0EC11DDFCA0003A3B23 /* cleanerinsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */; }; - 8416E15411DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8416E15311DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp */; }; 84BE5526119B20CA0092BDA7 /* handyfuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BE5524119B20CA0092BDA7 /* handyfuncs.cpp */; }; - 84BFF69211C4CDC1000DB417 /* ofxSimpleGuiButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */; }; - 84BFF69311C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67211C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp */; }; - 84BFF69411C4CDC1000DB417 /* ofxSimpleGuiContent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67411C4CDC1000DB417 /* ofxSimpleGuiContent.cpp */; }; - 84BFF69511C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67611C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.cpp */; }; - 84BFF69611C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67811C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.cpp */; }; - 84BFF69711C4CDC1000DB417 /* ofxSimpleGuiOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67A11C4CDC1000DB417 /* ofxSimpleGuiOption.cpp */; }; - 84BFF69811C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67C11C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.cpp */; }; - 84BFF69911C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67E11C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.cpp */; }; - 84BFF69A11C4CDC1000DB417 /* ofxSimpleGuiSlider2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF68011C4CDC1000DB417 /* ofxSimpleGuiSlider2d.cpp */; }; - 84BFF69B11C4CDC1000DB417 /* ofxSimpleGuiTitle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF68511C4CDC1000DB417 /* ofxSimpleGuiTitle.cpp */; }; - 84BFF69C11C4CDC1000DB417 /* ofxSimpleGuiToggle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF68711C4CDC1000DB417 /* ofxSimpleGuiToggle.cpp */; }; - 84BFF69D11C4CDC1000DB417 /* ofxSimpleGuiConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF68911C4CDC1000DB417 /* ofxSimpleGuiConfig.cpp */; }; - 84BFF69E11C4CDC1000DB417 /* ofxSimpleGuiControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF68B11C4CDC1000DB417 /* ofxSimpleGuiControl.cpp */; }; - 84BFF69F11C4CDC1000DB417 /* ofxSimpleGuiPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF68E11C4CDC1000DB417 /* ofxSimpleGuiPage.cpp */; }; - 84BFF6A011C4CDC1000DB417 /* ofxSimpleGuiToo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF69011C4CDC1000DB417 /* ofxSimpleGuiToo.cpp */; }; - 84BFF6A511C4CE9F000DB417 /* ofxMSAInteractiveObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF6A311C4CE9F000DB417 /* ofxMSAInteractiveObject.cpp */; }; 84BFF6B111C4CECD000DB417 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF6AA11C4CECD000DB417 /* tinyxml.cpp */; }; 84BFF6B211C4CECD000DB417 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF6AC11C4CECD000DB417 /* tinyxmlerror.cpp */; }; 84BFF6B311C4CECD000DB417 /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF6AD11C4CECD000DB417 /* tinyxmlparser.cpp */; }; @@ -105,48 +106,52 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 840F2C9311E7869C00C5CD20 /* ofxMSAInteractiveObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxMSAInteractiveObject.cpp; sourceTree = "<group>"; }; + 840F2C9411E7869C00C5CD20 /* ofxMSAInteractiveObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxMSAInteractiveObject.h; sourceTree = "<group>"; }; + 840F2CCC11E788F200C5CD20 /* ofxSimpleGuiButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiButton.cpp; sourceTree = "<group>"; }; + 840F2CCD11E788F200C5CD20 /* ofxSimpleGuiButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiButton.h; sourceTree = "<group>"; }; + 840F2CCE11E788F200C5CD20 /* ofxSimpleGuiColorPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiColorPicker.cpp; sourceTree = "<group>"; }; + 840F2CCF11E788F200C5CD20 /* ofxSimpleGuiColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiColorPicker.h; sourceTree = "<group>"; }; + 840F2CD011E788F200C5CD20 /* ofxSimpleGuiComboBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiComboBox.cpp; sourceTree = "<group>"; }; + 840F2CD111E788F200C5CD20 /* ofxSimpleGuiComboBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiComboBox.h; sourceTree = "<group>"; }; + 840F2CD211E788F200C5CD20 /* ofxSimpleGuiContent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiContent.cpp; sourceTree = "<group>"; }; + 840F2CD311E788F200C5CD20 /* ofxSimpleGuiContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiContent.h; sourceTree = "<group>"; }; + 840F2CD411E788F200C5CD20 /* ofxSimpleGuiFPSCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiFPSCounter.cpp; sourceTree = "<group>"; }; + 840F2CD511E788F200C5CD20 /* ofxSimpleGuiFPSCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiFPSCounter.h; sourceTree = "<group>"; }; + 840F2CD611E788F200C5CD20 /* ofxSimpleGuiMovieSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiMovieSlider.cpp; sourceTree = "<group>"; }; + 840F2CD711E788F200C5CD20 /* ofxSimpleGuiMovieSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiMovieSlider.h; sourceTree = "<group>"; }; + 840F2CD811E788F200C5CD20 /* ofxSimpleGuiOption.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiOption.cpp; sourceTree = "<group>"; }; + 840F2CD911E788F200C5CD20 /* ofxSimpleGuiOption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiOption.h; sourceTree = "<group>"; }; + 840F2CDA11E788F200C5CD20 /* ofxSimpleGuiOptionGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiOptionGroup.cpp; sourceTree = "<group>"; }; + 840F2CDB11E788F200C5CD20 /* ofxSimpleGuiOptionGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiOptionGroup.h; sourceTree = "<group>"; }; + 840F2CDC11E788F200C5CD20 /* ofxSimpleGuiQuadWarp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiQuadWarp.cpp; sourceTree = "<group>"; }; + 840F2CDD11E788F200C5CD20 /* ofxSimpleGuiQuadWarp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiQuadWarp.h; sourceTree = "<group>"; }; + 840F2CDE11E788F200C5CD20 /* ofxSimpleGuiSlider2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiSlider2d.cpp; sourceTree = "<group>"; }; + 840F2CDF11E788F300C5CD20 /* ofxSimpleGuiSlider2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSlider2d.h; sourceTree = "<group>"; }; + 840F2CE011E788F300C5CD20 /* ofxSimpleGuiSliderBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSliderBase.h; sourceTree = "<group>"; }; + 840F2CE111E788F300C5CD20 /* ofxSimpleGuiSliderFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSliderFloat.h; sourceTree = "<group>"; }; + 840F2CE211E788F300C5CD20 /* ofxSimpleGuiSliderInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSliderInt.h; sourceTree = "<group>"; }; + 840F2CE311E788F300C5CD20 /* ofxSimpleGuiTitle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiTitle.cpp; sourceTree = "<group>"; }; + 840F2CE411E788F300C5CD20 /* ofxSimpleGuiTitle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiTitle.h; sourceTree = "<group>"; }; + 840F2CE511E788F300C5CD20 /* ofxSimpleGuiToggle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiToggle.cpp; sourceTree = "<group>"; }; + 840F2CE611E788F300C5CD20 /* ofxSimpleGuiToggle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiToggle.h; sourceTree = "<group>"; }; + 840F2CE711E788F300C5CD20 /* ofxSimpleGuiConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiConfig.cpp; sourceTree = "<group>"; }; + 840F2CE811E788F300C5CD20 /* ofxSimpleGuiConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiConfig.h; sourceTree = "<group>"; }; + 840F2CE911E788F300C5CD20 /* ofxSimpleGuiControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiControl.cpp; sourceTree = "<group>"; }; + 840F2CEA11E788F300C5CD20 /* ofxSimpleGuiControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiControl.h; sourceTree = "<group>"; }; + 840F2CEB11E788F300C5CD20 /* ofxSimpleGuiIncludes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiIncludes.h; sourceTree = "<group>"; }; + 840F2CEC11E788F300C5CD20 /* ofxSimpleGuiPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiPage.cpp; sourceTree = "<group>"; }; + 840F2CED11E788F300C5CD20 /* ofxSimpleGuiPage.cpp.rej */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ofxSimpleGuiPage.cpp.rej; sourceTree = "<group>"; }; + 840F2CEE11E788F300C5CD20 /* ofxSimpleGuiPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiPage.h; sourceTree = "<group>"; }; + 840F2CEF11E788F300C5CD20 /* ofxSimpleGuiToo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiToo.cpp; sourceTree = "<group>"; }; + 840F2CF011E788F300C5CD20 /* ofxSimpleGuiToo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiToo.h; sourceTree = "<group>"; }; + 840F2CF111E788F300C5CD20 /* ofxSimpleGuiToo.h.rej */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ofxSimpleGuiToo.h.rej; sourceTree = "<group>"; }; + 840F2DF711E7B63300C5CD20 /* ofxSimpleGuiTextInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiTextInput.h; sourceTree = "<group>"; }; + 840F2DF811E7B63300C5CD20 /* ofxSimpleGuiTextInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiTextInput.cpp; sourceTree = "<group>"; }; 8416E04311DA9FBA003A3B23 /* openFrameworks.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = openFrameworks.a; path = ../../../../of/of_preRelease_v0061_osx_FAT/libs/openFrameworksCompiled/lib/osx/openFrameworks.a; sourceTree = SOURCE_ROOT; }; 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cleanerinsert.cpp; sourceTree = "<group>"; }; - 8416E15211DE13D6003A3B23 /* ofxSimpleGuiComboBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiComboBox.h; sourceTree = "<group>"; }; - 8416E15311DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiComboBox.cpp; sourceTree = "<group>"; }; 84BE5524119B20CA0092BDA7 /* handyfuncs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = handyfuncs.cpp; sourceTree = "<group>"; }; 84BE5525119B20CA0092BDA7 /* handyfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = handyfuncs.h; sourceTree = "<group>"; }; - 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiButton.cpp; sourceTree = "<group>"; }; - 84BFF67111C4CDC1000DB417 /* ofxSimpleGuiButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiButton.h; sourceTree = "<group>"; }; - 84BFF67211C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiColorPicker.cpp; sourceTree = "<group>"; }; - 84BFF67311C4CDC1000DB417 /* ofxSimpleGuiColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiColorPicker.h; sourceTree = "<group>"; }; - 84BFF67411C4CDC1000DB417 /* ofxSimpleGuiContent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiContent.cpp; sourceTree = "<group>"; }; - 84BFF67511C4CDC1000DB417 /* ofxSimpleGuiContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiContent.h; sourceTree = "<group>"; }; - 84BFF67611C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiFPSCounter.cpp; sourceTree = "<group>"; }; - 84BFF67711C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiFPSCounter.h; sourceTree = "<group>"; }; - 84BFF67811C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiMovieSlider.cpp; sourceTree = "<group>"; }; - 84BFF67911C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiMovieSlider.h; sourceTree = "<group>"; }; - 84BFF67A11C4CDC1000DB417 /* ofxSimpleGuiOption.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiOption.cpp; sourceTree = "<group>"; }; - 84BFF67B11C4CDC1000DB417 /* ofxSimpleGuiOption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiOption.h; sourceTree = "<group>"; }; - 84BFF67C11C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiOptionGroup.cpp; sourceTree = "<group>"; }; - 84BFF67D11C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiOptionGroup.h; sourceTree = "<group>"; }; - 84BFF67E11C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiQuadWarp.cpp; sourceTree = "<group>"; }; - 84BFF67F11C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiQuadWarp.h; sourceTree = "<group>"; }; - 84BFF68011C4CDC1000DB417 /* ofxSimpleGuiSlider2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiSlider2d.cpp; sourceTree = "<group>"; }; - 84BFF68111C4CDC1000DB417 /* ofxSimpleGuiSlider2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSlider2d.h; sourceTree = "<group>"; }; - 84BFF68211C4CDC1000DB417 /* ofxSimpleGuiSliderBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSliderBase.h; sourceTree = "<group>"; }; - 84BFF68311C4CDC1000DB417 /* ofxSimpleGuiSliderFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSliderFloat.h; sourceTree = "<group>"; }; - 84BFF68411C4CDC1000DB417 /* ofxSimpleGuiSliderInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiSliderInt.h; sourceTree = "<group>"; }; - 84BFF68511C4CDC1000DB417 /* ofxSimpleGuiTitle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiTitle.cpp; sourceTree = "<group>"; }; - 84BFF68611C4CDC1000DB417 /* ofxSimpleGuiTitle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiTitle.h; sourceTree = "<group>"; }; - 84BFF68711C4CDC1000DB417 /* ofxSimpleGuiToggle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiToggle.cpp; sourceTree = "<group>"; }; - 84BFF68811C4CDC1000DB417 /* ofxSimpleGuiToggle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiToggle.h; sourceTree = "<group>"; }; - 84BFF68911C4CDC1000DB417 /* ofxSimpleGuiConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiConfig.cpp; sourceTree = "<group>"; }; - 84BFF68A11C4CDC1000DB417 /* ofxSimpleGuiConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiConfig.h; sourceTree = "<group>"; }; - 84BFF68B11C4CDC1000DB417 /* ofxSimpleGuiControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiControl.cpp; sourceTree = "<group>"; }; - 84BFF68C11C4CDC1000DB417 /* ofxSimpleGuiControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiControl.h; sourceTree = "<group>"; }; - 84BFF68D11C4CDC1000DB417 /* ofxSimpleGuiIncludes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiIncludes.h; sourceTree = "<group>"; }; - 84BFF68E11C4CDC1000DB417 /* ofxSimpleGuiPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiPage.cpp; sourceTree = "<group>"; }; - 84BFF68F11C4CDC1000DB417 /* ofxSimpleGuiPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiPage.h; sourceTree = "<group>"; }; - 84BFF69011C4CDC1000DB417 /* ofxSimpleGuiToo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiToo.cpp; sourceTree = "<group>"; }; - 84BFF69111C4CDC1000DB417 /* ofxSimpleGuiToo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiToo.h; sourceTree = "<group>"; }; - 84BFF6A311C4CE9F000DB417 /* ofxMSAInteractiveObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxMSAInteractiveObject.cpp; sourceTree = "<group>"; }; - 84BFF6A411C4CE9F000DB417 /* ofxMSAInteractiveObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxMSAInteractiveObject.h; sourceTree = "<group>"; }; 84BFF6A811C4CECD000DB417 /* install.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = install.xml; sourceTree = "<group>"; }; 84BFF6AA11C4CECD000DB417 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = "<group>"; }; 84BFF6AB11C4CECD000DB417 /* tinyxml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tinyxml.h; sourceTree = "<group>"; }; @@ -258,77 +263,81 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 84BFF66D11C4CD9C000DB417 /* addons */ = { + 840F2C9211E7869C00C5CD20 /* src */ = { isa = PBXGroup; children = ( - 84BFF6A711C4CECD000DB417 /* ofxXmlSettings */, - 84BFF6A211C4CE9F000DB417 /* src */, - 84BFF66E11C4CDC1000DB417 /* src */, + 840F2C9311E7869C00C5CD20 /* ofxMSAInteractiveObject.cpp */, + 840F2C9411E7869C00C5CD20 /* ofxMSAInteractiveObject.h */, ); - name = addons; - sourceTree = "<group>"; + name = src; + path = ../../../ofxMSA/ofxMSAInteractiveObject/src; + sourceTree = SOURCE_ROOT; }; - 84BFF66E11C4CDC1000DB417 /* src */ = { + 840F2CCA11E788F200C5CD20 /* src */ = { isa = PBXGroup; children = ( - 84BFF66F11C4CDC1000DB417 /* Controls */, - 84BFF68911C4CDC1000DB417 /* ofxSimpleGuiConfig.cpp */, - 84BFF68A11C4CDC1000DB417 /* ofxSimpleGuiConfig.h */, - 84BFF68B11C4CDC1000DB417 /* ofxSimpleGuiControl.cpp */, - 84BFF68C11C4CDC1000DB417 /* ofxSimpleGuiControl.h */, - 84BFF68D11C4CDC1000DB417 /* ofxSimpleGuiIncludes.h */, - 84BFF68E11C4CDC1000DB417 /* ofxSimpleGuiPage.cpp */, - 84BFF68F11C4CDC1000DB417 /* ofxSimpleGuiPage.h */, - 84BFF69011C4CDC1000DB417 /* ofxSimpleGuiToo.cpp */, - 84BFF69111C4CDC1000DB417 /* ofxSimpleGuiToo.h */, + 840F2CCB11E788F200C5CD20 /* Controls */, + 840F2CE711E788F300C5CD20 /* ofxSimpleGuiConfig.cpp */, + 840F2CE811E788F300C5CD20 /* ofxSimpleGuiConfig.h */, + 840F2CE911E788F300C5CD20 /* ofxSimpleGuiControl.cpp */, + 840F2CEA11E788F300C5CD20 /* ofxSimpleGuiControl.h */, + 840F2CEB11E788F300C5CD20 /* ofxSimpleGuiIncludes.h */, + 840F2CEC11E788F300C5CD20 /* ofxSimpleGuiPage.cpp */, + 840F2CED11E788F300C5CD20 /* ofxSimpleGuiPage.cpp.rej */, + 840F2CEE11E788F300C5CD20 /* ofxSimpleGuiPage.h */, + 840F2CEF11E788F300C5CD20 /* ofxSimpleGuiToo.cpp */, + 840F2CF011E788F300C5CD20 /* ofxSimpleGuiToo.h */, + 840F2CF111E788F300C5CD20 /* ofxSimpleGuiToo.h.rej */, ); name = src; - path = ../../../../of/of_preRelease_v0061_osx_FAT/addons/ofxSimpleGuiToo/src; + path = ../../../ofxMSA/ofxSimpleGuiToo/src; sourceTree = SOURCE_ROOT; }; - 84BFF66F11C4CDC1000DB417 /* Controls */ = { + 840F2CCB11E788F200C5CD20 /* Controls */ = { isa = PBXGroup; children = ( - 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */, - 84BFF67111C4CDC1000DB417 /* ofxSimpleGuiButton.h */, - 84BFF67211C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp */, - 84BFF67311C4CDC1000DB417 /* ofxSimpleGuiColorPicker.h */, - 84BFF67411C4CDC1000DB417 /* ofxSimpleGuiContent.cpp */, - 84BFF67511C4CDC1000DB417 /* ofxSimpleGuiContent.h */, - 84BFF67611C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.cpp */, - 84BFF67711C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.h */, - 84BFF67811C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.cpp */, - 84BFF67911C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.h */, - 84BFF67A11C4CDC1000DB417 /* ofxSimpleGuiOption.cpp */, - 84BFF67B11C4CDC1000DB417 /* ofxSimpleGuiOption.h */, - 84BFF67C11C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.cpp */, - 84BFF67D11C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.h */, - 84BFF67E11C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.cpp */, - 84BFF67F11C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.h */, - 84BFF68011C4CDC1000DB417 /* ofxSimpleGuiSlider2d.cpp */, - 84BFF68111C4CDC1000DB417 /* ofxSimpleGuiSlider2d.h */, - 84BFF68211C4CDC1000DB417 /* ofxSimpleGuiSliderBase.h */, - 84BFF68311C4CDC1000DB417 /* ofxSimpleGuiSliderFloat.h */, - 84BFF68411C4CDC1000DB417 /* ofxSimpleGuiSliderInt.h */, - 84BFF68511C4CDC1000DB417 /* ofxSimpleGuiTitle.cpp */, - 84BFF68611C4CDC1000DB417 /* ofxSimpleGuiTitle.h */, - 84BFF68711C4CDC1000DB417 /* ofxSimpleGuiToggle.cpp */, - 84BFF68811C4CDC1000DB417 /* ofxSimpleGuiToggle.h */, - 8416E15211DE13D6003A3B23 /* ofxSimpleGuiComboBox.h */, - 8416E15311DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp */, + 840F2CCC11E788F200C5CD20 /* ofxSimpleGuiButton.cpp */, + 840F2CCD11E788F200C5CD20 /* ofxSimpleGuiButton.h */, + 840F2CCE11E788F200C5CD20 /* ofxSimpleGuiColorPicker.cpp */, + 840F2CCF11E788F200C5CD20 /* ofxSimpleGuiColorPicker.h */, + 840F2CD011E788F200C5CD20 /* ofxSimpleGuiComboBox.cpp */, + 840F2CD111E788F200C5CD20 /* ofxSimpleGuiComboBox.h */, + 840F2CD211E788F200C5CD20 /* ofxSimpleGuiContent.cpp */, + 840F2CD311E788F200C5CD20 /* ofxSimpleGuiContent.h */, + 840F2CD411E788F200C5CD20 /* ofxSimpleGuiFPSCounter.cpp */, + 840F2CD511E788F200C5CD20 /* ofxSimpleGuiFPSCounter.h */, + 840F2CD611E788F200C5CD20 /* ofxSimpleGuiMovieSlider.cpp */, + 840F2CD711E788F200C5CD20 /* ofxSimpleGuiMovieSlider.h */, + 840F2CD811E788F200C5CD20 /* ofxSimpleGuiOption.cpp */, + 840F2CD911E788F200C5CD20 /* ofxSimpleGuiOption.h */, + 840F2CDA11E788F200C5CD20 /* ofxSimpleGuiOptionGroup.cpp */, + 840F2CDB11E788F200C5CD20 /* ofxSimpleGuiOptionGroup.h */, + 840F2CDC11E788F200C5CD20 /* ofxSimpleGuiQuadWarp.cpp */, + 840F2CDD11E788F200C5CD20 /* ofxSimpleGuiQuadWarp.h */, + 840F2CDE11E788F200C5CD20 /* ofxSimpleGuiSlider2d.cpp */, + 840F2CDF11E788F300C5CD20 /* ofxSimpleGuiSlider2d.h */, + 840F2CE011E788F300C5CD20 /* ofxSimpleGuiSliderBase.h */, + 840F2CE111E788F300C5CD20 /* ofxSimpleGuiSliderFloat.h */, + 840F2CE211E788F300C5CD20 /* ofxSimpleGuiSliderInt.h */, + 840F2CE311E788F300C5CD20 /* ofxSimpleGuiTitle.cpp */, + 840F2CE411E788F300C5CD20 /* ofxSimpleGuiTitle.h */, + 840F2CE511E788F300C5CD20 /* ofxSimpleGuiToggle.cpp */, + 840F2CE611E788F300C5CD20 /* ofxSimpleGuiToggle.h */, + 840F2DF711E7B63300C5CD20 /* ofxSimpleGuiTextInput.h */, + 840F2DF811E7B63300C5CD20 /* ofxSimpleGuiTextInput.cpp */, ); path = Controls; sourceTree = "<group>"; }; - 84BFF6A211C4CE9F000DB417 /* src */ = { + 84BFF66D11C4CD9C000DB417 /* addons */ = { isa = PBXGroup; children = ( - 84BFF6A311C4CE9F000DB417 /* ofxMSAInteractiveObject.cpp */, - 84BFF6A411C4CE9F000DB417 /* ofxMSAInteractiveObject.h */, + 840F2CCA11E788F200C5CD20 /* src */, + 840F2C9211E7869C00C5CD20 /* src */, + 84BFF6A711C4CECD000DB417 /* ofxXmlSettings */, ); - name = src; - path = ../../../../of/of_preRelease_v0061_osx_FAT/addons/ofxMSAInteractiveObject/src; - sourceTree = SOURCE_ROOT; + name = addons; + sourceTree = "<group>"; }; 84BFF6A711C4CECD000DB417 /* ofxXmlSettings */ = { isa = PBXGroup; @@ -767,22 +776,6 @@ E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */, E4B69E210A3A1BDC003C02F2 /* testApp.cpp in Sources */, 84BE5526119B20CA0092BDA7 /* handyfuncs.cpp in Sources */, - 84BFF69211C4CDC1000DB417 /* ofxSimpleGuiButton.cpp in Sources */, - 84BFF69311C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp in Sources */, - 84BFF69411C4CDC1000DB417 /* ofxSimpleGuiContent.cpp in Sources */, - 84BFF69511C4CDC1000DB417 /* ofxSimpleGuiFPSCounter.cpp in Sources */, - 84BFF69611C4CDC1000DB417 /* ofxSimpleGuiMovieSlider.cpp in Sources */, - 84BFF69711C4CDC1000DB417 /* ofxSimpleGuiOption.cpp in Sources */, - 84BFF69811C4CDC1000DB417 /* ofxSimpleGuiOptionGroup.cpp in Sources */, - 84BFF69911C4CDC1000DB417 /* ofxSimpleGuiQuadWarp.cpp in Sources */, - 84BFF69A11C4CDC1000DB417 /* ofxSimpleGuiSlider2d.cpp in Sources */, - 84BFF69B11C4CDC1000DB417 /* ofxSimpleGuiTitle.cpp in Sources */, - 84BFF69C11C4CDC1000DB417 /* ofxSimpleGuiToggle.cpp in Sources */, - 84BFF69D11C4CDC1000DB417 /* ofxSimpleGuiConfig.cpp in Sources */, - 84BFF69E11C4CDC1000DB417 /* ofxSimpleGuiControl.cpp in Sources */, - 84BFF69F11C4CDC1000DB417 /* ofxSimpleGuiPage.cpp in Sources */, - 84BFF6A011C4CDC1000DB417 /* ofxSimpleGuiToo.cpp in Sources */, - 84BFF6A511C4CE9F000DB417 /* ofxMSAInteractiveObject.cpp in Sources */, 84BFF6B111C4CECD000DB417 /* tinyxml.cpp in Sources */, 84BFF6B211C4CECD000DB417 /* tinyxmlerror.cpp in Sources */, 84BFF6B311C4CECD000DB417 /* tinyxmlparser.cpp in Sources */, @@ -797,7 +790,24 @@ 84BFF89311C4E7DB000DB417 /* shell.cpp in Sources */, 84BFF89811C4ECE1000DB417 /* AlgorhythmicAudioIO.cpp in Sources */, 8416E0EC11DDFCA0003A3B23 /* cleanerinsert.cpp in Sources */, - 8416E15411DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp in Sources */, + 840F2C9511E7869C00C5CD20 /* ofxMSAInteractiveObject.cpp in Sources */, + 840F2CF211E788F300C5CD20 /* ofxSimpleGuiButton.cpp in Sources */, + 840F2CF311E788F300C5CD20 /* ofxSimpleGuiColorPicker.cpp in Sources */, + 840F2CF411E788F300C5CD20 /* ofxSimpleGuiComboBox.cpp in Sources */, + 840F2CF511E788F300C5CD20 /* ofxSimpleGuiContent.cpp in Sources */, + 840F2CF611E788F300C5CD20 /* ofxSimpleGuiFPSCounter.cpp in Sources */, + 840F2CF711E788F300C5CD20 /* ofxSimpleGuiMovieSlider.cpp in Sources */, + 840F2CF811E788F300C5CD20 /* ofxSimpleGuiOption.cpp in Sources */, + 840F2CF911E788F300C5CD20 /* ofxSimpleGuiOptionGroup.cpp in Sources */, + 840F2CFA11E788F300C5CD20 /* ofxSimpleGuiQuadWarp.cpp in Sources */, + 840F2CFB11E788F300C5CD20 /* ofxSimpleGuiSlider2d.cpp in Sources */, + 840F2CFC11E788F300C5CD20 /* ofxSimpleGuiTitle.cpp in Sources */, + 840F2CFD11E788F300C5CD20 /* ofxSimpleGuiToggle.cpp in Sources */, + 840F2CFE11E788F300C5CD20 /* ofxSimpleGuiConfig.cpp in Sources */, + 840F2CFF11E788F300C5CD20 /* ofxSimpleGuiControl.cpp in Sources */, + 840F2D0011E788F300C5CD20 /* ofxSimpleGuiPage.cpp in Sources */, + 840F2D0111E788F300C5CD20 /* ofxSimpleGuiToo.cpp in Sources */, + 840F2DF911E7B63300C5CD20 /* ofxSimpleGuiTextInput.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: algorhythmicSorting/ofAlgorhythmicSorting/bin/data/Courier New.ttf =================================================================== (Binary files differ) Property changes on: algorhythmicSorting/ofAlgorhythmicSorting/bin/data/Courier New.ttf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-07-02 15:24:58 UTC (rev 218) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-07-09 23:50:22 UTC (rev 219) @@ -91,6 +91,7 @@ return m_inited; } + void* sortstuffhelper (void * arg); void SortingMan::SortStuff() { Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h 2010-07-02 15:24:58 UTC (rev 218) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.h 2010-07-09 23:50:22 UTC (rev 219) @@ -2,6 +2,8 @@ #define __SORTINGMAN__ #include <pthread.h> +#include <string> +using std::string; enum SortAlgorithms { eBubbleSortAlgorithm = 0, @@ -52,13 +54,15 @@ void SetAlgorithm(SortAlgorithms newType); void GenerateNewArray(int size); - bool ShouldStop(){return m_shouldStop;} + bool ShouldStop() {return m_shouldStop;} - void ToggleLooping(){m_looping = !m_looping;} - bool IsLooping(){return m_looping;} + void ToggleLooping() {m_looping = !m_looping;} + bool IsLooping() {return m_looping;} - int GetArraySize(){return m_size;} + int GetArraySize() {return m_size;} + double* GetArray() {return m_lastSort.array; } + protected: //private constructor - Singleton. SortingMan(); Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-02 15:24:58 UTC (rev 218) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-09 23:50:22 UTC (rev 219) @@ -12,19 +12,30 @@ int myInt1; bool startButton; bool genButton; +string textInput; //-------------------------------------------------------------- void testApp::setup(){ - arrayFont.loadFont("courier.ttf",8, false, true); - arrayFont.setLineHeight(10.0f); + bDrawConsole = true; + bDrawBars = false; + currFontSize = 10; + arrayFont.loadFont("Courier New.ttf", currFontSize, true, true); +// arrayFont.setLineHeight(10.0f); ofBackground(255,255,255); - + speedSliderVal = speedSliderVal_old = 25; gui.addTitle("A group"); gui.addSlider("speed", speedSliderVal, 0.01, 1000); arraysize = prev_arraysize = 10; gui.addSlider("Array Size", arraysize, 2, 200); gui.addToggle("Loop", bLoop); - gui.addComboBox("algos", algonum, eNumSortAlgorithms,gAlgoStrings); + + string algostrings[eNumSortAlgorithms]; + for(int i = 0;i<eNumSortAlgorithms;i++) + algostrings[i] = gAlgoStrings[i]; + + ofxSimpleGuiComboBox& box = gui.addComboBox("Sorting Algorithm", algonum, eNumSortAlgorithms,algostrings); + gui.addTextInput("number",textInput); + gui.addButton("Start", startButton); gui.addButton("Generate New Array", genButton); @@ -281,21 +292,37 @@ //// if (!bNoise) sprintf(reportString, "%s (%fhz)", reportString, targetFrequency); // // ofDrawBitmapString(reportString,80,600); + drawBars(); drawConsole(); - drawBars(); + if(drawGUI) gui.draw(); } +#define kArraysStringMaxSize 32767 +static char lastDrawString[kArraysStringMaxSize+1]=""; + void testApp::drawBars() { - //we only need the last string to draw bars. + if(!bDrawBars) + return; + //we don't need to worry about thread safety because the array pointer and size is only modified on the main thread. + //the values change and there's a chance of corruption, but probably it won't happen and we can take a glitch. + int len = SortingMan::Instance()->GetArraySize(); + double* array = SortingMan::Instance()->GetArray(); + float y1,y2; + for(int i=0;i<len;i++){ + ofSetColor(0x666666); + y1 = ofGetHeight()/2; + y2 = (1.0 + (array[i]/-100.0)) * ofGetHeight()/2; + ofRect(ofGetWidth()*((float)i/len), mymin(y1,y2), + (float)ofGetWidth()/len, fabs(y1-y2)); + } } void testApp::drawConsole() { -#define kArraysStringMaxSize 32767 - static char lastDrawString[kArraysStringMaxSize+1]=""; + static int bufsize = 0; char* poppedString; unsigned int popsize; @@ -322,9 +349,19 @@ #define kConsoleX 10 #define kConsoleY 10 + int desiredFontSize = 10; + if(prev_arraysize > 30) + { + desiredFontSize = mymax(10.0 - (prev_arraysize/30.0), 4.0); + } + if(currFontSize!=desiredFontSize) { + arrayFont.loadFont("Courier New.ttf",desiredFontSize,true, true); + currFontSize = desiredFontSize; + } + int width = ofGetWidth(); int screenHeight = ofGetHeight() - kConsoleY; - int lineHeight = arrayFont.getLineHeight() *1.3; + int lineHeight = arrayFont.getLineHeight(); int n = bufsize; int lines=0; while(--n > -1) { @@ -356,9 +393,10 @@ - if(lastDrawString){ + if(lastDrawString && bDrawConsole){ ofSetColor(0xFF0000); - ofDrawBitmapString(lastDrawString,kConsoleX,kConsoleY); +// ofDrawBitmapString(lastDrawString,kConsoleX,kConsoleY); + arrayFont.drawString(lastDrawString,kConsoleX,kConsoleY); } } @@ -459,12 +497,13 @@ volume = MIN(volume, 1); } else if(key == 'c') { drawGUI=!drawGUI; - }else if(key == 'v') + }else if(key == '2') { - }else if(key == 'w') + bDrawBars = !bDrawBars; + }else if(key == '1') { //fade in and outloops. - useLoopFade=!useLoopFade; + bDrawConsole=!bDrawConsole; }else if(key == 'a') { //set mouse mode Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h 2010-07-02 15:24:58 UTC (rev 218) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h 2010-07-09 23:50:22 UTC (rev 219) @@ -136,7 +136,10 @@ pthread_mutex_t loopMutex; ofTrueTypeFont arrayFont; + int currFontSize; bool drawGUI; + bool bDrawConsole; + bool bDrawBars; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-02 15:25:05
|
Revision: 218 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=218&view=rev Author: mchinen Date: 2010-07-02 15:24:58 +0000 (Fri, 02 Jul 2010) Log Message: ----------- adding combobox and gui features to our of sorting project Modified Paths: -------------- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h Added Paths: ----------- algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch Modified: algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-07-02 11:58:28 UTC (rev 217) +++ algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-07-02 15:24:58 UTC (rev 218) @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 8416E04411DA9FBA003A3B23 /* openFrameworks.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8416E04311DA9FBA003A3B23 /* openFrameworks.a */; }; 8416E0EC11DDFCA0003A3B23 /* cleanerinsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */; }; + 8416E15411DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8416E15311DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp */; }; 84BE5526119B20CA0092BDA7 /* handyfuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BE5524119B20CA0092BDA7 /* handyfuncs.cpp */; }; 84BFF69211C4CDC1000DB417 /* ofxSimpleGuiButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */; }; 84BFF69311C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67211C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp */; }; @@ -106,6 +107,8 @@ /* Begin PBXFileReference section */ 8416E04311DA9FBA003A3B23 /* openFrameworks.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = openFrameworks.a; path = ../../../../of/of_preRelease_v0061_osx_FAT/libs/openFrameworksCompiled/lib/osx/openFrameworks.a; sourceTree = SOURCE_ROOT; }; 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cleanerinsert.cpp; sourceTree = "<group>"; }; + 8416E15211DE13D6003A3B23 /* ofxSimpleGuiComboBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxSimpleGuiComboBox.h; sourceTree = "<group>"; }; + 8416E15311DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiComboBox.cpp; sourceTree = "<group>"; }; 84BE5524119B20CA0092BDA7 /* handyfuncs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = handyfuncs.cpp; sourceTree = "<group>"; }; 84BE5525119B20CA0092BDA7 /* handyfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = handyfuncs.h; sourceTree = "<group>"; }; 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiButton.cpp; sourceTree = "<group>"; }; @@ -311,6 +314,8 @@ 84BFF68611C4CDC1000DB417 /* ofxSimpleGuiTitle.h */, 84BFF68711C4CDC1000DB417 /* ofxSimpleGuiToggle.cpp */, 84BFF68811C4CDC1000DB417 /* ofxSimpleGuiToggle.h */, + 8416E15211DE13D6003A3B23 /* ofxSimpleGuiComboBox.h */, + 8416E15311DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp */, ); path = Controls; sourceTree = "<group>"; @@ -792,6 +797,7 @@ 84BFF89311C4E7DB000DB417 /* shell.cpp in Sources */, 84BFF89811C4ECE1000DB417 /* AlgorhythmicAudioIO.cpp in Sources */, 8416E0EC11DDFCA0003A3B23 /* cleanerinsert.cpp in Sources */, + 8416E15411DE13D6003A3B23 /* ofxSimpleGuiComboBox.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt (rev 0) +++ algorhythmicSorting/ofAlgorhythmicSorting/ofxpatchreadme.txt 2010-07-02 15:24:58 UTC (rev 218) @@ -0,0 +1,10 @@ +To build this project you'll have to patch open frameworks' simpleguitoo add on to get things we use such as combo boxes. + +0.If you have applied previous patches you'll have to delete the contents of ofxSimpleGuiToo and do an svn update there to get it fresh (so the patch can be applied.) + +1.cd to the open frameworks gui add on directory: +cd ~/of/of_preRelease_v0061_osx_FAT/addons/ofxSimpleGuiToo +2.apply the patch +patch -p0 < ~/svncheckouts/algorhythmics/algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch + +Then build and run. Added: algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch (rev 0) +++ algorhythmicSorting/ofAlgorhythmicSorting/ofxsimpleguicombobox_1.patch 2010-07-02 15:24:58 UTC (rev 218) @@ -0,0 +1,374 @@ +Index: src/ofxSimpleGuiConfig.cpp +=================================================================== +--- src/ofxSimpleGuiConfig.cpp (revision 204) ++++ src/ofxSimpleGuiConfig.cpp (working copy) +@@ -47,6 +47,7 @@ + toggleHeight = titleHeight; + buttonHeight = titleHeight; + slider2DTextHeight = titleHeight * 1.5; ++ comboBoxHeight = 15; + + + padding.set (titleHeight/2, 10); +Index: src/Controls/ofxSimpleGuiComboBox.cpp +=================================================================== +--- src/Controls/ofxSimpleGuiComboBox.cpp (revision 0) ++++ src/Controls/ofxSimpleGuiComboBox.cpp (revision 0) +@@ -0,0 +1,163 @@ ++/* ++ * ofxSimpleGuiComboBox.cpp ++ * AlgorhythmicSorting ++ * ++ * Created by Administrator on 7/2/10. ++ * Copyright 2010 __MyCompanyName__. All rights reserved. ++ * ++ */ ++ ++#include "ofxSimpleGuiComboBox.h" ++#include "ofxSimpleGuiPage.h" ++ ++ofxSimpleGuiComboBox::ofxSimpleGuiComboBox(string name, int &choice_out, int numChoices, ofxSimpleGuiPage *owner, const char** choiceTitles ) : ++ofxSimpleGuiControl(name), ++m_selectedChoice(choice_out), ++m_page(owner) { ++ m_selectedChoice = m_mouseChoice = 0; ++ if(numChoices <=1) ++ numChoices = 1; ++ m_numChoices = numChoices; ++ m_hasFocus=false; ++ beenPressed = false; ++ char* titlestring; ++ ++ for(int i=0;i<numChoices;i++){ ++ titlestring = (char*)malloc(choiceTitles?strlen(choiceTitles[i]):10); ++ if(choiceTitles) ++ strcpy(titlestring,choiceTitles[i]); ++ else { ++ strcpy(titlestring,"1"); ++ titlestring[0]+=i; //only valid for 9 entries ++ } ++ m_choiceTitles.push_back(titlestring); ++// free(titlestring); ++ } ++ controlType = "ComboBox"; ++ setup(); ++} ++ ++ofxSimpleGuiComboBox::~ofxSimpleGuiComboBox() { ++ //kill the strings ++ for(int i =0;i<m_numChoices;i++) { ++ free(m_choiceTitles[i]); ++ } ++} ++ ++void ofxSimpleGuiComboBox::SetTitle(int index, const char* title) { ++ //we don't check null and index bounds. ++ free(m_choiceTitles[index]); ++ char* titlestring = (char*)malloc(strlen(title)); ++ strcpy(titlestring, title); ++ m_choiceTitles[index]=titlestring; ++} ++ ++void ofxSimpleGuiComboBox::setup() { ++ setSize(config->gridSize.x - config->padding.x, config->comboBoxHeight); ++} ++ ++void ofxSimpleGuiComboBox::loadFromXML(ofxXmlSettings &XML) { ++//TODO: ++// set(XML.getValue("controls:" + controlType + "_" + key + ":value", 0)); ++} ++ ++void ofxSimpleGuiComboBox::saveToXML(ofxXmlSettings &XML) { ++//TODO: ++ XML.addTag(controlType + "_" + key); ++ XML.pushTag(controlType + "_" + key); ++ XML.addValue("name", name); ++// XML.addValue("value", getValue()); ++ XML.popTag(); ++} ++ ++void ofxSimpleGuiComboBox::keyPressed( int key ) { ++//TODO do up/down ++// if(key==keyboardShortcut) toggle(); ++} ++ ++int ofxSimpleGuiComboBox::getChoice() { ++ return m_selectedChoice; ++} ++ ++//press was outside - handle. ++void onPressOutside(int x, int y, int button) { ++ ++} ++ ++void ofxSimpleGuiComboBox::onPress(int x, int y, int button) { ++ beenPressed = true; ++ ++ //a click toggles focus state if we are off ++ if(!m_hasFocus) { ++ //expand the height for all choices ++ setSize(config->gridSize.x - config->padding.x, config->comboBoxHeight * m_numChoices); ++ m_hasFocus = true; ++ //notify that we want to steal all events from the page ++ m_page->SetEventStealingControl(*this); ++ } ++} ++ ++void ofxSimpleGuiComboBox::onPressOutside(int x, int y, int button){ ++ ++} ++ ++ ++void ofxSimpleGuiComboBox::onDragOver(int x, int y, int button){ ++ //same behavior as mouse move ++ onMouseMove(x,y); ++} ++ ++void ofxSimpleGuiComboBox::onMouseMove(int x, int y) { ++ if(m_hasFocus) { ++ //see which index was selected. ++ m_mouseChoice = (y-this->y)/config->comboBoxHeight; ++ //TODO:replace with OF constrain macro. ++ m_mouseChoice = m_mouseChoice < 0?0:(m_mouseChoice>= m_numChoices? m_numChoices-1:m_mouseChoice); ++ } ++} ++ ++void ofxSimpleGuiComboBox::onRelease(int x, int y, int button) { ++ if(m_hasFocus) { ++ //see which index was selected, but only if the user actually moved around. ++ m_selectedChoice = m_mouseChoice >= 0? m_mouseChoice : m_selectedChoice; ++ ++ //a release toggles focus state if we are on - TODO: unless x and y don't change ++ m_hasFocus = false; ++ setSize(config->gridSize.x - config->padding.x, config->comboBoxHeight); ++ //also let the page know we don't need to steal all the events and draw over anymore ++ m_page->ReleaseEventStealingControl(); ++ ++ } ++} ++ ++void ofxSimpleGuiComboBox::draw(float x, float y) { ++ setPos(x, y); ++ ++ glPushMatrix(); ++ glTranslatef(x, y, 0); ++ ++ ofEnableAlphaBlending(); ++ ofFill(); ++ setTextBGColor(); ++ ofRect(0, 0, width, height); ++ ++ setTextColor(); ++ if(!m_hasFocus) ++ ofDrawBitmapString(m_choiceTitles[m_selectedChoice], 3, 10);//15); ++ else { ++ for(int i=0; i < m_numChoices; i++) { ++ setTextColor(); ++ //invert for selected choice ++ if(i==m_mouseChoice){ ++ //draw a text colored rect so we can see the inverse ++ ofRect(0, i*config->comboBoxHeight, width, config->comboBoxHeight); ++ setTextBGColor(); ++ } ++ ++ ofDrawBitmapString(m_choiceTitles[i], 3, config->comboBoxHeight * i + 10);//15); ++ } ++ } ++ ofDisableAlphaBlending(); ++ ++ glPopMatrix(); ++} +Index: src/Controls/ofxSimpleGuiComboBox.h +=================================================================== +--- src/Controls/ofxSimpleGuiComboBox.h (revision 0) ++++ src/Controls/ofxSimpleGuiComboBox.h (revision 0) +@@ -0,0 +1,43 @@ ++/* ++ * ofxSimpleGuiComboBox.h ++ * open frameworks simpleguitoo ++ * ++ * Created by Michael Chinen on 7/2/10. ++ * ++ */ ++ ++#pragma once ++ ++#include "ofxSimpleGuiControl.h" ++ ++ ++class ofxSimpleGuiPage; ++class ofxSimpleGuiComboBox : public ofxSimpleGuiControl { ++public: ++ ++ ofxSimpleGuiComboBox(string name, int &choice_out, int numChoices, ofxSimpleGuiPage *owner, const char** choiceTitles = NULL ) ; ++ virtual ~ofxSimpleGuiComboBox(); ++ ++ void setup(); ++ void loadFromXML(ofxXmlSettings &XML); ++ void saveToXML(ofxXmlSettings &XML); ++ void keyPressed( int key ); ++ ++ int getChoice(); ++ void onPress(int x, int y, int button); ++ void onRelease(int x, int y, int button); ++ void draw(float x, float y); ++ ++ void SetTitle(int index, const char* title); ++ virtual void onPressOutside(int x, int y, int button); ++ virtual void onMouseMove(int x, int y); ++ virtual void onDragOver(int x, int y, int button); ++protected: ++ int m_mouseChoice; ++ int &m_selectedChoice; ++ int m_numChoices; ++ bool m_hasFocus; ++ vector<char*> m_choiceTitles; ++ ofxSimpleGuiPage* m_page; ++ bool beenPressed; ++}; +Index: src/ofxSimpleGuiToo.h +=================================================================== +--- src/ofxSimpleGuiToo.h (revision 204) ++++ src/ofxSimpleGuiToo.h (working copy) +@@ -98,7 +98,7 @@ + ofxSimpleGuiTitle &addTitle(string name="", float height = 0); + ofxSimpleGuiToggle &addToggle(string name, bool &value); + ofxSimpleGuiColorPicker &addColorPicker(string name, float *values); +- ++ ofxSimpleGuiComboBox &addComboBox(string name, int &choice_out, int numChoices,const char** choiceTitles=NULL); + void draw(); + + +Index: src/ofxSimpleGuiConfig.h +=================================================================== +--- src/ofxSimpleGuiConfig.h (revision 204) ++++ src/ofxSimpleGuiConfig.h (working copy) +@@ -48,6 +48,7 @@ + float sliderTextHeight; + float slider2DTextHeight; + float titleHeight; ++ float comboBoxHeight; + + ofPoint padding; + ofPoint offset; +Index: src/ofxSimpleGuiIncludes.h +=================================================================== +--- src/ofxSimpleGuiIncludes.h (revision 204) ++++ src/ofxSimpleGuiIncludes.h (working copy) +@@ -47,5 +47,6 @@ + #include "ofxSimpleGuiToggle.h" + #include "ofxSimpleGuiTitle.h" + #include "ofxSimpleGuiColorPicker.h" ++#include "ofxSimpleGuiComboBox.h" + //#include "ofxSimpleGuiOption.h" + //#include "ofxSimpleGuiOptionGroup.h" +Index: src/ofxSimpleGuiPage.cpp +=================================================================== +--- src/ofxSimpleGuiPage.cpp (revision 204) ++++ src/ofxSimpleGuiPage.cpp (working copy) +@@ -40,6 +40,7 @@ + disableAllEvents(); + width = 0; + height = ofGetHeight(); ++ eventStealingControl = NULL; + setXMLName(name + "_settings.xml"); + } + +@@ -202,26 +203,41 @@ + } + + ++ofxSimpleGuiComboBox &ofxSimpleGuiPage::addComboBox(string name, int &choice_out, int numChoices,const char** choiceTitles) { ++ return (ofxSimpleGuiComboBox &)addControl(* new ofxSimpleGuiComboBox(name, choice_out, numChoices, this, choiceTitles)); ++} + + ++ ++ + void ofxSimpleGuiPage::update(ofEventArgs &e) { + for(int i=0; i<controls.size(); i++) controls[i]->update(); + } + + + void ofxSimpleGuiPage::mouseMoved(ofMouseEventArgs &e) { +- for(int i=0; i<controls.size(); i++) controls[i]->_mouseMoved(e); ++ if(eventStealingControl) ++ eventStealingControl->_mouseMoved(e); ++ else ++ for(int i=0; i<controls.size(); i++) controls[i]->_mouseMoved(e); + } + + void ofxSimpleGuiPage::mousePressed(ofMouseEventArgs &e) { ++ if(eventStealingControl) ++ eventStealingControl->_mousePressed(e); ++ else + for(int i=0; i<controls.size(); i++) controls[i]->_mousePressed(e); + } + + void ofxSimpleGuiPage::mouseDragged(ofMouseEventArgs &e) { ++ if(eventStealingControl) ++ eventStealingControl->_mouseDragged(e); + for(int i=0; i<controls.size(); i++) controls[i]->_mouseDragged(e); + } + + void ofxSimpleGuiPage::mouseReleased(ofMouseEventArgs &e) { ++ if(eventStealingControl) ++ eventStealingControl->_mouseReleased(e); + for(int i=0; i<controls.size(); i++) controls[i]->_mouseReleased(e); + } + +@@ -233,3 +249,11 @@ + for(int i=0; i<controls.size(); i++) controls[i]->_keyReleased(e); + } + ++void ofxSimpleGuiPage::SetEventStealingControl(ofxSimpleGuiControl &control) { ++ eventStealingControl = &control; ++} ++void ofxSimpleGuiPage::ReleaseEventStealingControl() { ++ eventStealingControl = NULL; ++} ++ ++ +Index: src/ofxSimpleGuiToo.cpp +=================================================================== +--- src/ofxSimpleGuiToo.cpp (revision 204) ++++ src/ofxSimpleGuiToo.cpp (working copy) +@@ -321,7 +321,12 @@ + } + + ++ofxSimpleGuiComboBox &ofxSimpleGuiToo::addComboBox(string name, int &choice_out, int numChoices,const char** choiceTitles) { ++ if(!config) setup(); ++ return pages[currentPage]->addComboBox(name, choice_out, numChoices, choiceTitles); ++} + ++ + //void ofxSimpleGuiToo::setup(ofEventArgs &e) { + void ofxSimpleGuiToo::update(ofEventArgs &e) { + if(changePage) { +Index: src/ofxSimpleGuiPage.h +=================================================================== +--- src/ofxSimpleGuiPage.h (revision 204) ++++ src/ofxSimpleGuiPage.h (working copy) +@@ -65,8 +65,11 @@ + ofxSimpleGuiTitle &addTitle(string name="", float height = 0); + ofxSimpleGuiToggle &addToggle(string name, bool &value); + ofxSimpleGuiColorPicker &addColorPicker(string name, float *values); ++ ofxSimpleGuiComboBox &addComboBox(string name, int &choice_out, int numChoices, const char** choiceTitles=NULL); + +- ++ void SetEventStealingControl(ofxSimpleGuiControl &control); ++ void ReleaseEventStealingControl(); ++ + // void setup(ofEventArgs &e); + void update(ofEventArgs &e); + // void draw(ofEventArgs &e); +@@ -82,6 +85,8 @@ + + protected: + vector <ofxSimpleGuiControl*> controls; ++ //some controls can take over focus (e.g. combo box,) which means events should only be passed to them ++ ofxSimpleGuiControl* eventStealingControl; + float getNextY(float y); + ofxXmlSettings XML; + string xmlFilename; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-02 11:58:28 UTC (rev 217) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-02 15:24:58 UTC (rev 218) @@ -4,13 +4,14 @@ #include "ofxSimpleGuiToo.h" #include "SortingMan.h" #include "AlgorhythmicAudioIO.h" +#include "ofxSimpleGuiComboBox.h" #define kTatsumiRingBufferSize (44100*60) float speedSliderVal; float speedSliderVal_old; int myInt1; -bool myBool1; bool startButton; +bool genButton; //-------------------------------------------------------------- void testApp::setup(){ arrayFont.loadFont("courier.ttf",8, false, true); @@ -20,10 +21,14 @@ speedSliderVal = speedSliderVal_old = 25; gui.addTitle("A group"); gui.addSlider("speed", speedSliderVal, 0.01, 1000); - gui.addSlider("myInt1", myInt1, 5, 10); - gui.addToggle("myBool1", myBool1); + arraysize = prev_arraysize = 10; + gui.addSlider("Array Size", arraysize, 2, 200); + gui.addToggle("Loop", bLoop); + gui.addComboBox("algos", algonum, eNumSortAlgorithms,gAlgoStrings); gui.addButton("Start", startButton); + gui.addButton("Generate New Array", genButton); + gui.show(); drawGUI=true; //flags init @@ -47,6 +52,16 @@ SortingMan::Instance()->SortStuff(); } + if(genButton || prev_arraysize != arraysize){ + genButton = false; + prev_arraysize = arraysize; + SortingMan::Instance()->GenerateNewArray(arraysize); + } + + SortingMan::Instance()->SetAlgorithm((SortAlgorithms)algonum); + if(bLoop != SortingMan::Instance()->IsLooping()) + SortingMan::Instance()->ToggleLooping(); + //stupid hack to make sliders work with functions if(speedSliderVal != speedSliderVal_old) { speedSliderVal_old = speedSliderVal; @@ -275,11 +290,11 @@ void testApp::drawBars() { - + //we only need the last string to draw bars. } void testApp::drawConsole() { -#define kArraysStringMaxSize 32768 +#define kArraysStringMaxSize 32767 static char lastDrawString[kArraysStringMaxSize+1]=""; static int bufsize = 0; char* poppedString; @@ -308,8 +323,8 @@ #define kConsoleY 10 int width = ofGetWidth(); - int screenHeight = ofGetHeight(); - int lineHeight = arrayFont.getLineHeight(); + int screenHeight = ofGetHeight() - kConsoleY; + int lineHeight = arrayFont.getLineHeight() *1.3; int n = bufsize; int lines=0; while(--n > -1) { @@ -317,7 +332,7 @@ if(lastDrawString[n]=='\n') { lines++; } - if(lines*lineHeight>screenHeight*0.95) + if(lines*lineHeight>screenHeight) { n++;//restore n to point after the endline. break; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h 2010-07-02 11:58:28 UTC (rev 217) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.h 2010-07-02 15:24:58 UTC (rev 218) @@ -78,7 +78,12 @@ float volume; float ycurs; int downsampleTimes; + int algonum; + int arraysize, prev_arraysize; +bool bLoop; + + float * lAudio; float * rAudio; float * lIn; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-07-02 11:58:35
|
Revision: 217 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=217&view=rev Author: mchinen Date: 2010-07-02 11:58:28 +0000 (Fri, 02 Jul 2010) Log Message: ----------- merging changes from the SortingGUI project. WE SHOULD NOT CHANGE THE old cocoa SortingGUI PROJECT FROM NOW ON. Modified Paths: -------------- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.h algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/bubble.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/heap.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/msort.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/msort.h algorhythmicSorting/ofAlgorhythmicSorting/src/quicksort.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/shell.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.h algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp Added Paths: ----------- algorhythmicSorting/ofAlgorhythmicSorting/src/cleanerinsert.cpp Modified: algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/AlgorhythmicSorting.xcodeproj/project.pbxproj 2010-07-02 11:58:28 UTC (rev 217) @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 8416E04411DA9FBA003A3B23 /* openFrameworks.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8416E04311DA9FBA003A3B23 /* openFrameworks.a */; }; + 8416E0EC11DDFCA0003A3B23 /* cleanerinsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */; }; 84BE5526119B20CA0092BDA7 /* handyfuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BE5524119B20CA0092BDA7 /* handyfuncs.cpp */; }; 84BFF69211C4CDC1000DB417 /* ofxSimpleGuiButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */; }; 84BFF69311C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF67211C4CDC1000DB417 /* ofxSimpleGuiColorPicker.cpp */; }; @@ -29,7 +31,6 @@ 84BFF6B311C4CECD000DB417 /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF6AD11C4CECD000DB417 /* tinyxmlparser.cpp */; }; 84BFF6B411C4CECD000DB417 /* ofxXmlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF6AF11C4CECD000DB417 /* ofxXmlSettings.cpp */; }; 84BFF84611C4E60C000DB417 /* libfmodex.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BFF84511C4E60C000DB417 /* libfmodex.dylib */; }; - 84BFF85211C4E69E000DB417 /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BFF85011C4E64E000DB417 /* openFrameworksDebug.a */; }; 84BFF87911C4E744000DB417 /* bubble.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF86311C4E744000DB417 /* bubble.cpp */; }; 84BFF87B11C4E744000DB417 /* libportaudio.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BFF86711C4E744000DB417 /* libportaudio.a */; }; 84BFF87D11C4E744000DB417 /* msort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BFF86A11C4E744000DB417 /* msort.cpp */; }; @@ -103,6 +104,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 8416E04311DA9FBA003A3B23 /* openFrameworks.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = openFrameworks.a; path = ../../../../of/of_preRelease_v0061_osx_FAT/libs/openFrameworksCompiled/lib/osx/openFrameworks.a; sourceTree = SOURCE_ROOT; }; + 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cleanerinsert.cpp; sourceTree = "<group>"; }; 84BE5524119B20CA0092BDA7 /* handyfuncs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = handyfuncs.cpp; sourceTree = "<group>"; }; 84BE5525119B20CA0092BDA7 /* handyfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = handyfuncs.h; sourceTree = "<group>"; }; 84BFF67011C4CDC1000DB417 /* ofxSimpleGuiButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxSimpleGuiButton.cpp; sourceTree = "<group>"; }; @@ -220,7 +223,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 84BFF85211C4E69E000DB417 /* openFrameworksDebug.a in Frameworks */, 84BFF87B11C4E744000DB417 /* libportaudio.a in Frameworks */, E45BE0AA0E8CC67C009D7055 /* GLee.a in Frameworks */, E45BE2E40E8CC69C009D7055 /* rtAudio.a in Frameworks */, @@ -246,6 +248,7 @@ E4C246DA10CCAE22004149E2 /* freeimage.a in Frameworks */, 84BFF84611C4E60C000DB417 /* libfmodex.dylib in Frameworks */, 84BFF8AB11C4F069000DB417 /* AudioUnit.framework in Frameworks */, + 8416E04411DA9FBA003A3B23 /* openFrameworks.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -578,6 +581,7 @@ E4B69E1C0A3A1BDC003C02F2 /* src */ = { isa = PBXGroup; children = ( + 8416E0EB11DDFCA0003A3B23 /* cleanerinsert.cpp */, 84BFF89611C4ECE1000DB417 /* AlgorhythmicAudioIO.cpp */, 84BFF89711C4ECE1000DB417 /* AlgorhythmicAudioIO.h */, 84BFF88E11C4E7DB000DB417 /* heap.cpp */, @@ -605,6 +609,7 @@ E4C2422310CC54B6004149E2 /* openFrameworks */ = { isa = PBXGroup; children = ( + 8416E04311DA9FBA003A3B23 /* openFrameworks.a */, 84BFF84811C4E64E000DB417 /* openFrameworksLib.xcodeproj */, ); name = openFrameworks; @@ -786,6 +791,7 @@ 84BFF89211C4E7DB000DB417 /* insert.cpp in Sources */, 84BFF89311C4E7DB000DB417 /* shell.cpp in Sources */, 84BFF89811C4ECE1000DB417 /* AlgorhythmicAudioIO.cpp in Sources */, + 8416E0EC11DDFCA0003A3B23 /* cleanerinsert.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -868,6 +874,7 @@ "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", ); LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../../libs/freeimage/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_14 = "\"$(SRCROOT)/../../../libs/fmodex/lib/osx\""; @@ -878,6 +885,7 @@ LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_5 = "\"$(SRCROOT)/../../../libs/poco/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_6 = "\"$(SRCROOT)/../../../libs/rtAudio/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7 = "\"$(SRCROOT)/src\""; + LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8 = "\"$(SRCROOT)/../../../../of/of_preRelease_v0061_osx_FAT/libs/openFrameworksCompiled/lib/osx\""; PREBINDING = NO; PRODUCT_NAME = "$(TARGET_NAME)Universal"; WRAPPER_EXTENSION = app; @@ -995,6 +1003,7 @@ "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", ); LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../../libs/freeimage/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_14 = "\"$(SRCROOT)/../../../libs/fmodex/lib/osx\""; @@ -1005,6 +1014,7 @@ LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_5 = "\"$(SRCROOT)/../../../libs/poco/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_6 = "\"$(SRCROOT)/../../../libs/rtAudio/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7 = "\"$(SRCROOT)/src\""; + LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8 = "\"$(SRCROOT)/../../../../of/of_preRelease_v0061_osx_FAT/libs/openFrameworksCompiled/lib/osx\""; PREBINDING = NO; PRODUCT_NAME = "$(TARGET_NAME)Debug"; WRAPPER_EXTENSION = app; @@ -1048,6 +1058,7 @@ "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", ); LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../../libs/freeimage/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_14 = "\"$(SRCROOT)/../../../libs/fmodex/lib/osx\""; @@ -1058,6 +1069,7 @@ LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_5 = "\"$(SRCROOT)/../../../libs/poco/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_6 = "\"$(SRCROOT)/../../../libs/rtAudio/lib/osx\""; LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7 = "\"$(SRCROOT)/src\""; + LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8 = "\"$(SRCROOT)/../../../../of/of_preRelease_v0061_osx_FAT/libs/openFrameworksCompiled/lib/osx\""; PREBINDING = NO; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -3,7 +3,7 @@ * * Created by michael takezo chinen on 12/19/09. */ - + #include "AlgorhythmicAudioIO.h" #include "portaudio.h" #include "stdio.h" @@ -22,24 +22,135 @@ #define NUM_CHANNELS 2 typedef struct -{ - float left_phase; - float right_phase; -} -paTestData; + { + float left_phase; + float right_phase; + } + paTestData; static paTestData data; static bool gManagerCreated = false; +//actual desired params +float nb_freq =1000; +float nb_bw = 0.99; +float nb_phase = 0.0; +float nb_amp = 0.5; + +//for real time state keeping +bool laston; +float lastfreq; +float lastamp; +float lastbw; +float instfreq; +float phase; +float targetfreq; +int samplesTillNextTarget; +bool initedForRealTime = false; + + +//generate a block the size of the buffer. +void NoiseBandFillFrame(float* buf, int length, float vol) +{ + if(!initedForRealTime) + { + + laston = false; + lastfreq = nb_freq; + lastamp = 0.0; + lastbw = nb_bw; + instfreq = nb_freq; + targetfreq = nb_freq; + + phase = nb_phase; + samplesTillNextTarget=0; + initedForRealTime = true; + } + + + double phaseAdd; + bool on = true; + float amp = lastamp; + + float freq = lastfreq; + float bw =lastbw; + //for quick ref + + float curamp; + float curfreq; + float curbw; + + curamp = nb_amp; + curfreq = nb_freq; + curbw = nb_bw; + + + laston = on; + + if(on||laston) + { + for(int j = 0 ; j<length ; j++ ) + { + + bw = curbw;//curpg->Interpolate(3,lastbw,curbw,length==0?1.0:(float)j/(float)length,bwFormat); + freq = curfreq;//curpg->Interpolate(1,lastfreq,curfreq,length==0?1.0:(float)j/(float)length,freqFormat); + amp = curamp;//curpg->Interpolate(0,lastamp,on?curamp:0.0,length==0?1.0:(float)j/(float)length,ampFormat); + + + //see if we need a new target + if(samplesTillNextTarget <0) + { + targetfreq = randfloat(freq*bw*2.0)+freq*(1.0-bw); //assumes bw <1.0 + samplesTillNextTarget = randint(44100/mymax(2.0,freq))+1.0; + }else + { + samplesTillNextTarget--; + } + + instfreq = instfreq + (targetfreq-instfreq)/mymax(1.0,samplesTillNextTarget); + + phaseAdd = instfreq*2.0*3.141592/44100.0; + //phaseAdd += phaseAdd* (randfloat(bw*2)-bw); + + phase += phaseAdd; + while(phase>2.0*3.141592) + phase-=2.0*3.141592; + + buf[j*2]+=amp*sin(phase) *vol; + buf[j*2+1]+=amp*sin(phase) * vol; + + + } + }else + { + //advance phase, but try not to loose precision with a large to small addition. + phaseAdd = length*freq*2.0*3.141592/44100.0; + while(phaseAdd>2.0*3.141592) + phaseAdd-=2.0*3.141592; + + phase += phaseAdd; + while(phase>2.0*3.141592) + phase-=2.0*3.141592; + } + + lastamp = amp; + lastfreq = freq; + lastbw = bw; + +} + + +int nb_samples_left = 0; +int nb_samples_total = 0; /* This routine will be called by the PortAudio engine when audio is needed. -** It may called at interrupt level on some machines so don't do anything -** that could mess up the system like calling malloc() or free(). -*/ + ** It may called at interrupt level on some machines so don't do anything + ** that could mess up the system like calling malloc() or free(). + */ static int SortingPortAudioCallback( const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *userData ) + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) { int noisefactor; noisefactor = 1; @@ -49,10 +160,12 @@ float freqMin = AlgorhythmicAudioIO::Instance()->GetFreqMin(); float freqRange = AlgorhythmicAudioIO::Instance()->GetFreqMax() - freqMin; bool notesOn = AlgorhythmicAudioIO::Instance()->IsNotesOn(); - + bool sepOn = AlgorhythmicAudioIO::Instance()->IsSeperatorOn(); + bool click = false; + for( int z = 0; z < NUM_CHANNELS; z++ ) memset(((float*)outputBuffer)+framesPerBuffer*z, 0, framesPerBuffer*sizeof(float)); -// memcpy(((float*)outputBuffer)+framesPerBuffer*z,noisearray+randint(framesPerBuffer*(noisefactor)),framesPerBuffer*sizeof(float)); + // memcpy(((float*)outputBuffer)+framesPerBuffer*z,noisearray+randint(framesPerBuffer*(noisefactor)),framesPerBuffer*sizeof(float)); delete [] noisearray; //sonify stuff @@ -62,6 +175,15 @@ if(dataa->usedouble) { AlgorhythmicAudioIO::Instance()->LockSortData(); + + //if this is a fresh array + if(!dataa->seperatorPlayed) + { + click = true; + nb_samples_left = nb_samples_total = dataa->duration * SAMPLE_RATE/8; + dataa->seperatorPlayed=true; + } + //double array. //duration is for the entire array. //get the index of the number we are interested in by looking at how much we've played back so far. @@ -82,15 +204,33 @@ freq = freqRange*exp2cursor(freq/20000.0)+freqMin; pan = ((float)index)/dataa->doubleArraySize; } + + if(sepOn && nb_samples_left) { + nb_freq = 10000/(dataa->seperatorDepth + 1); + + NoiseBandFillFrame((float*) outputBuffer, framesPerBuffer, vol); + for(int i=0;i<framesPerBuffer;i++) { + ((float*)outputBuffer)[i*2] *= (float)nb_samples_left/nb_samples_total; + ((float*)outputBuffer)[i*2+1] *= (float)nb_samples_left/nb_samples_total; + if(nb_samples_left>0) + nb_samples_left--; + } + } + for(unsigned int i = 0; i < framesPerBuffer*NUM_CHANNELS; i+=2) { float sinval; sinval = sin(dataa->phase); - if(notesOn || index == dataa->doubleArraySize) - { - ((float*)outputBuffer)[i] = sinval * (1.0-pan) * vol; - ((float*)outputBuffer)[i+1] = sinval * pan * vol; - } + if(notesOn)//old sep || (index == dataa->doubleArraySize && sepOn )) + { + ((float*)outputBuffer)[i] += sinval * (1.0-pan) * vol * 0.5; + ((float*)outputBuffer)[i+1] += sinval * pan * vol * 0.5; + } + if(1 || click) { + float bassmult = 16*dataa->seperatorDepth+1; + // ((float*)outputBuffer)[i] += vol*2*((float)mymax(0,(framesPerBuffer*NUM_CHANNELS-(i*bassmult)))/framesPerBuffer*NUM_CHANNELS); + // ((float*)outputBuffer)[i+1] += vol*2*((float)mymax(0,(framesPerBuffer*NUM_CHANNELS-(i*bassmult)))/framesPerBuffer*NUM_CHANNELS); + } //inc phase if we are under the size, otherwise use noise. if(index < dataa->doubleArraySize) { @@ -108,7 +248,7 @@ } } dataa->sampleCursor++; - + //see if we've stepped over a boundry if(dataa->sampleCursor > dataa->durations[dataa->lastNoteIndex] * SAMPLE_RATE) { @@ -125,8 +265,6 @@ } } } - - } AlgorhythmicAudioIO::Instance()->unLockSortData(); } @@ -161,37 +299,40 @@ { m_stream = NULL; } - + AlgorhythmicAudioIO::~AlgorhythmicAudioIO() { //[[NSAutoreleasePool alloc] init]; //[audioDataMutex release]; } +//Change Preset values bool AlgorhythmicAudioIO::Init() { - PaError err; - m_speed = 0.2; - m_seperatorOn=m_notesOn=true; - m_freqMin = 20; - m_freqMax = 20000; - m_volume = 0.8; - - /* Initialize our data for use by callback. */ - data.left_phase = data.right_phase = 0.0; + PaError err; + m_speed = 0.025; + m_seperatorOn=m_notesOn=true; + m_freqMin = 100; + m_freqMax = 4000; + m_volume = 0.8; + + /* Initialize our data for use by callback. */ + data.left_phase = data.right_phase = 0.0; mzsortdata.intArray = NULL; mzsortdata.doubleArray = NULL; mzsortdata.durations = NULL; - mzsortdata.lastNoteIndex=0; - mzsortdata.durationsSize=0; - /* Initialize library before making any other calls. */ - err = Pa_Initialize(); - - m_inited= err == paNoError ; - -// audioDataMutex = [[NSLock alloc] init]; - - return m_inited; + mzsortdata.lastNoteIndex=0; + mzsortdata.durationsSize=0; + mzsortdata.seperatorDepth = 0; + mzsortdata.seperatorPlayed = true; + /* Initialize library before making any other calls. */ + err = Pa_Initialize(); + + m_inited= err == paNoError ; + + // audioDataMutex = [[NSLock alloc] init]; + + return m_inited; } void AlgorhythmicAudioIO::ChangeFreqMin(float min) @@ -211,14 +352,18 @@ void AlgorhythmicAudioIO::unLockSortData() { - + pthread_mutex_unlock(&audioDataMutex);// [audioDataMutex unlock]; } +void AlgorhythmicAudioIO::PlaySeperator(int depth){ + mzsortdata.seperatorDepth = depth; + mzsortdata.seperatorPlayed = false; +} -float AlgorhythmicAudioIO::PlayDoubleArray(double * array, int size, float duration)//, int swapaindex, int swapbindex) +float AlgorhythmicAudioIO::PlayDoubleArray(double * array, int size)//, int swapaindex, int swapbindex) { mzsortdata.approxEvals+=size; - + if(array!=mzsortdata.doubleArray) { LockSortData(); @@ -226,9 +371,7 @@ mzsortdata.doubleArraySize=size; unLockSortData(); } - - mzsortdata.duration=duration; - + if(mzsortdata.durationsSize<size) { LockSortData(); @@ -244,7 +387,7 @@ mzsortdata.phase=0; mzsortdata.usedouble=true; - mzsortdata.lastNoteIndex=0; + mzsortdata.lastNoteIndex=0; float secDuration = 0.0; int min = INT_MAX; @@ -260,19 +403,19 @@ for(int i=0;i< size;i++) { //calculate the delay per note, -// mzsortdata.durations[i] = (((int)array[i])%20)/20.0 + 0.05 ; - + // mzsortdata.durations[i] = (((int)array[i])%20)/20.0 + 0.05 ; + //short notes -// { -// int chop; -// chop = (int)array[i]; -// mzsortdata.durations[i] = 0.05; -// while(fabs(chop) > 0) -// { -// mzsortdata.durations[i] *= 1.75; -// chop = chop/3; -// } -// } + // { + // int chop; + // chop = (int)array[i]; + // mzsortdata.durations[i] = 0.05; + // while(fabs(chop) > 0) + // { + // mzsortdata.durations[i] *= 1.75; + // chop = chop/3; + // } + // } { float cursor; cursor = (array[i] - min)/(max-min); @@ -280,20 +423,20 @@ cursor = exp2cursor(cursor,7); mzsortdata.durations[i] =m_speed;//(0.05 + cursor * (0.45) )* m_speed; } - + //we sum up the durations secDuration += mzsortdata.durations[i]; } //duration of break - mzsortdata.durations[size] = (m_seperatorOn?1.0:0.0) *m_speed; + mzsortdata.durations[size] = 0.0;//(m_seperatorOn?1.0:0.0) *m_speed; secDuration += mzsortdata.durations[size]; - + mzsortdata.duration=secDuration; return secDuration; } void AlgorhythmicAudioIO::PlayIntArray(int * array, int size, float duration) { - + mzsortdata.intArray=array; mzsortdata.intArraySize=size; mzsortdata.duration=duration; @@ -307,34 +450,34 @@ { if(!m_inited && !Init()) return false; - - PaError err; - /* Open an audio I/O stream. */ - err = Pa_OpenDefaultStream( &m_stream, - 0, /* no input channels */ - 2, /* stereo output */ - paFloat32, /* 32 bit floating point output */ - SAMPLE_RATE, - 256, /* frames per buffer */ - SortingPortAudioCallback, - &data ); - if( err != paNoError ) return false; - - err = Pa_StartStream( m_stream ); - if( err != paNoError ) return false; + + PaError err; + /* Open an audio I/O stream. */ + err = Pa_OpenDefaultStream( &m_stream, + 0, /* no input channels */ + 2, /* stereo output */ + paFloat32, /* 32 bit floating point output */ + SAMPLE_RATE, + 256, /* frames per buffer */ + SortingPortAudioCallback, + &data ); + if( err != paNoError ) return false; + + err = Pa_StartStream( m_stream ); + if( err != paNoError ) return false; } bool AlgorhythmicAudioIO::Stop() { - PaError err; - - err = Pa_StopStream( m_stream ); - if( err != paNoError ) return false; - err = Pa_CloseStream( m_stream ); - if( err != paNoError ) return false; + PaError err; + + err = Pa_StopStream( m_stream ); + if( err != paNoError ) return false; + err = Pa_CloseStream( m_stream ); + if( err != paNoError ) return false; } void AlgorhythmicAudioIO::Terminate() { - Pa_Terminate(); + Pa_Terminate(); } \ No newline at end of file Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.h 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/AlgorhythmicAudioIO.h 2010-07-02 11:58:28 UTC (rev 217) @@ -30,6 +30,8 @@ int lastNoteIndex; int approxEvals; + int seperatorDepth; + bool seperatorPlayed; }; class AlgorhythmicAudioIO @@ -46,9 +48,9 @@ void Terminate(); float GetSpeed(){return m_speed;} - + void PlaySeperator(int depth); void PlayIntArray(int * array, int size, float duration); - float PlayDoubleArray(double * array, int size, float duration); + float PlayDoubleArray(double * array, int size); void ChangeSpeed(float newSpeed){m_speed=newSpeed;} void ToggleSeperator(){m_seperatorOn = !m_seperatorOn;} @@ -62,6 +64,7 @@ float GetVolume(){return m_volume;} bool IsNotesOn(){return m_notesOn;} + bool IsSeperatorOn(){return m_seperatorOn;} float GetFreqMin(){return m_freqMin;} float GetFreqMax(){return m_freqMax;} Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/SortingMan.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -79,8 +79,8 @@ srand(stime); // stringLock = [[NSLock alloc] init]; - m_looping=true; - m_size = 13; + m_looping=false; + m_size = 10; m_lastSort.array = new double [m_size]; m_type = eBubbleSortAlgorithm; GenerateNewArray(m_size); @@ -141,7 +141,9 @@ // insert sorting -void PIKSRT(int N, double *ARR); +//void PIKSRT(int N, double *ARR); +//cleaner one +void insertion_sort(double a[], int length); void SHELL(int n, double *ARR) ; void HPSORT(int n, double *RA); int heapsort( double * data, int n ); @@ -149,7 +151,7 @@ void Order(double* p,double* q); void Bubble(double* something,int n); //bubble sort -void sort(double *a, int lo, int hi, bool toplevel=true); //merge sort +void sort(double *a, int lo, int hi, int depth = 0);//merge sort void dobubblesort (sort_params* params) { //printdoublearray(params->array, params->size); @@ -211,7 +213,7 @@ break; //DO insertion case eInsertionSortAlgorithm: - PIKSRT(n,a); + insertion_sort(a,n); break; case eShellSortAlgorithm: SHELL(n,a); Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/bubble.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/bubble.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/bubble.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -41,6 +41,7 @@ int i,j; for (i=0; i<n; i++) { + printseperator(0); for (j=n-1; i<j; j--){ // nested (verschachtelt) forloop | starts at the end of the array Order(&something[j-1], &something[j]); // first look and "Order" the last two values of array and then decrement until i (beginning of array) Added: algorhythmicSorting/ofAlgorhythmicSorting/src/cleanerinsert.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/cleanerinsert.cpp (rev 0) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/cleanerinsert.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -0,0 +1,95 @@ +/* Copyright (c) 2010 the authors listed at the following URL, and/or + the authors of referenced articles or incorporated external code: + http://en.literateprograms.org/Insertion_sort_(C)?action=history&offset=20081205204844 + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Retrieved from: http://en.literateprograms.org/Insertion_sort_(C)?oldid=15530 + */ + +#include <stdio.h> + +#include "SortingMan.h" +#include "sorthelp.h" + +/* Sort an array of integers */ +void insertion_sort(double a[], int length) +{ + int i; + for (i=0; i < length; i++) + { + /* Insert a[i] into the sorted sublist */ + int j; + double v = a[i]; + + for (j = i - 1; j >= 0; j--) + { +// printseperator(1); + if (a[j] <= v) { + + printdoublearray(a, length, 0, 0, j, i); // function defined somewhere else + break; + } + a[j + 1] = a[j]; + printdoublearray(a, length, 0, 0, j, j+1); // function defined somewhere else + + + // stopping the loop + if(SortingMan::Instance()->ShouldStop()) + return; + } + a[j + 1] = v; + printseperator(0); + printdoublearray(a, length, 0, 0, j+1, i); // function defined somewhere else + + + } +} +// +//void checkThatArrayIsSorted (int array[], int length) +//{ +// int i; +// for (i = 1; i < length; i+=1) +// { +// if (array[i-1] > array[i]) +// { +// printf("The array is not in sorted order at position %d\n", i-1); +// } +// } +//} +// +// +//int main(void) +//{ +// unsigned int i; +// int a[] = {5,1,9,3,2}; +// insertion_sort(a, sizeof(a)/sizeof(*a)); +// /* Print out a */ +// for(i=0; i<sizeof(a)/sizeof(*a); i++) +// { +// printf("%d\n", a[i]); +// } +// +// checkThatArrayIsSorted(a, sizeof(a)/sizeof(*a)); +// +// return 0; +//} +// +// Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/heap.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/heap.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/heap.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -16,7 +16,6 @@ #include <stdlib.h> #include <math.h> #include "sorthelp.h" - #include "SortingMan.h" @@ -32,8 +31,10 @@ * * * NOTE: The Heapsort method is a N Log2 N routine, * * and can be used for very large arrays. * - ****************************************************/ + ****************************************************/ +// Heap sort is like selection sort, but uses a heap (max-heap) + int heapsort( double * data, int n ) // lenght of array to sort { const int WIDTH= 8; // Number of childs per knot @@ -42,10 +43,12 @@ int m= (n + (WIDTH - 2)) / WIDTH; // first leaf in the heap int count= 0; int origchild, orign,origparent; + int depth ; orign= n; while ( 1 ) { + if ( m ) { // First Part of the Algorithm: Make a max-Heap parent= --m; @@ -63,9 +66,11 @@ origparent=parent; origchild = parent * WIDTH + 1; + depth =1; while ( (child= parent * WIDTH + 1) < n ) // erstes Kind; { // Abbruch am Ende des Heaps + printseperator(depth); w= n - child < WIDTH ? n - child : WIDTH; // Anzahl der vorhandenen Geschwister @@ -75,12 +80,12 @@ for ( max= 0, i= 1; i < w; ++i ) // größtes Kind suchen if ( data[child+i] > data[child+max] ) { - printdoublearray(data,orign,0,0, child+1, child+max); + printdoublearray(data,orign,0,0, child+i, child+max); max= i; } else { - printdoublearray(data,orign,0,0, child+1, child+max); + printdoublearray(data,orign,0,0, child+i, child+max); } child += max; @@ -90,16 +95,19 @@ data[parent]= data[child]; // größtes Kind nach oben rücken + if(SortingMan::Instance()->ShouldStop()) return 1; - parent= child; // in der Ebene darunter weitersuchen + depth++;//for our print/sonification } data[parent]= val; // versickerten Wert eintragen - if(parent-origchild>0) + if(parent-origchild>0) { + printseperator(0); printdoublearray(data, orign,0,0,parent,-1);//origparent, origchild-origparent); + } } return count; @@ -129,7 +137,6 @@ if(SortingMan::Instance()->ShouldStop()) return; - ir--; if (ir==1) { @@ -149,13 +156,10 @@ RA[i]=RA[j]; printdoublearray(RA, n,i,1); - if(SortingMan::Instance()->ShouldStop()) - return; - + return; - i=j; j=j+j; } else Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/msort.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/msort.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/msort.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -7,21 +7,12 @@ * * * C++ Version By J-P Moreau, Paris. * * ------------------------------------------------------ * - * SAMPLE RUN: * * * - * Initial table A: * - * 4.00 3.00 1.00 67.00 55.00 8.00 0.00 4.00 * - * -5.00 37.00 7.00 4.00 2.00 9.00 1.00 -1.00 * - * * - * Sorted table A: * - * -5.00 -1.00 0.00 1.00 1.00 2.00 3.00 4.00 * - * 4.00 4.00 7.00 8.00 9.00 37.00 55.00 67.00 * - * * *********************************************************/ + #include <stdio.h> #include <math.h> #include "sorthelp.h" - #include "SortingMan.h" /***************************************************** @@ -34,59 +25,100 @@ * Output: * * a : Table sorted in ascending order. * *****************************************************/ -void sort(double *a, int lo, int hi, bool toplevel) { + +// >>>>>>>>>>>>>>>> +// >>>>>>>>>>>>>>>> + +// merge sorting: +// assume that also 1 value is a sorted list, so next step you compare 2 values each of a array with x values, +// and then 4 and then 8 etc. There is natural merge sorts and inplace mergesorts. Natural mergesort uses more arrays. + + +void sort(double *a, int lo, int hi, int depth ) { // lo=0, hi=n-1 (only for the first call) + // lo and hi are index static double* original; static int originalsize; - if(SortingMan::Instance()->ShouldStop()) return; - - if(toplevel){ + if(depth==0){ original = a; originalsize = hi+1; } - if (lo>=hi) return; //no action - int mid = (lo + hi) / 2; +// >>>>>>>>>>>>>>>> + if (lo>=hi) return; // no action if the array is already sorted + + int mid = (lo + hi) / 2; // for example 9 / 2 = 4.5 >> 4 + + // Recursion breaks up the array in to smaller pieces before they are going to be sorted! + // Partition the list into two lists and sort them recursively - sort(a, lo, mid,false); - sort(a, mid + 1, hi,false); + sort(a, lo, mid, depth+1); // compare with void sort(double *a, int lo, int hi, bool toplevel) + sort(a, mid + 1, hi, depth+1); + // Merge the two sorted lists int start_hi = mid + 1; int end_lo = mid; - while ((lo <= end_lo) && (start_hi <= hi)) { - if (a[lo] < a[start_hi]) + + // [2,3] [5,4] [0,5] [4,6] >> 2 at index 3, 5 at index 4 ... + // code which is run on each piece of the whole array + while ((lo <= end_lo) && (start_hi <= hi)) { + printseperator(depth); + if (a[lo] < a[start_hi]) // if value of array a at index lo is smaller value at start-hi + + + { - printdoublearray(original, originalsize, lo, start_hi-lo, lo, start_hi); - lo++; + + printdoublearray(original, originalsize, lo, (start_hi-lo)+1, lo, start_hi); // Sonification + //blue means a[lo] < a[start_hi]. lo = first value of a chunk + + lo++; // lo gets incremented + + } + else { + // a[lo] >= a[start_hi] + // The next element comes from the second list, // move the a[start_hi] element into the next // position and shuffle all the other elements up. - double T = a[start_hi]; - for (int k = start_hi - 1; k >= lo; k--) { - a[k+1] = a[k]; + + double T = a[start_hi]; // [2,3] [5,4] [0,5] [4,6] + + // 0 (the value at index 5) goes to a storage called T + + + for (int k = start_hi-1; k >= lo; k--) { // count down from start-1 to lo + a[k+1] = a[k]; // [2,3] [5,4] [<0>,5] [4,6] >> [2,3] [5,4] [<5>,5] [4,6] + // = is like arrow pointing to left + + // makes a line of red values, because all values change } - a[lo] = T; + + a[lo] = T; + //print and play as an array segment instaid of a pair since the above for loop moves as a chunk (like memcpy) - printdoublearray(original, originalsize, lo, start_hi-lo); + printdoublearray(original, originalsize, lo, (start_hi-lo)+1); // Sonification + + // + lo++; end_lo++; start_hi++; + } - if(SortingMan::Instance()->ShouldStop()) return; - } } \ No newline at end of file Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/msort.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/msort.h 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/msort.h 2010-07-02 11:58:28 UTC (rev 217) @@ -7,4 +7,4 @@ * */ -void sort(double *a, int lo, int hi, bool toplevel=true); +void sort(double *a, int lo, int hi, int depth = 0); Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/quicksort.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/quicksort.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/quicksort.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -1,6 +1,7 @@ #include "sorthelp.h" +#include "SortingMan.h" -void quicksort_helper(double arr[], int low, int high) ; +void quicksort_helper(double arr[], int low, int high, int depth =0) ; /* sort everything inbetween `low' <-> `high' */ int orign; @@ -10,7 +11,8 @@ orign=n; quicksort_helper(arr,0,n-1); } -void quicksort_helper(double arr[], int low, int high) { + +void quicksort_helper(double arr[], int low, int high, int depth) { int i = low; int j = high; double y = 0; @@ -19,12 +21,19 @@ /* partition */ do { + printseperator(depth); /* find member above ... */ - while(arr[i] < z) i++; + while(arr[i] < z) { + printdoublearray(arr,orign,0,0, i, (low+high)/2); + i++; + } /* find element below ... */ - while(arr[j] > z) j--; - + while(arr[j] > z) { + printdoublearray(arr,orign,0,0, j, (low+high)/2); + j--; + } + if(i <= j) { /* swap two elements */ y = arr[i]; @@ -38,12 +47,16 @@ { printdoublearray(arr,orign,0,0, i, j); } + + if(SortingMan::Instance()->ShouldStop()) + return; + } while(i <= j); /* recurse */ if(low < j) - quicksort_helper(arr, low, j); + quicksort_helper(arr, low, j,depth+1); if(i < high) - quicksort_helper(arr, i, high); + quicksort_helper(arr, i, high,depth+1); } Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/shell.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/shell.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/shell.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -15,14 +15,12 @@ #include <stdlib.h> #include <math.h> #include "sorthelp.h" - #include "SortingMan.h" - /**************************************************** * Sorts an array ARR of length N in ascending order * * by the Shell-Mezgar method * @@ -51,19 +49,20 @@ LOGNB2=(double) floor(log(n)*ALN2I+TINY); m=n; for (nn=1; nn<=floor(LOGNB2); nn++) { + printseperator(0); m=m / 2; k=n-m; for (j=1; j<k+1; j++) { i=j; e10: l=i+m; + //if(j!=1) + // printseperator(1); if (ARR[l] < ARR[i]) { t=ARR[i]; ARR[i]=ARR[l]; ARR[l]=t; - if(SortingMan::Instance()->ShouldStop()) return; - printdoublearray(realArray, n,i-1,1,i-1,l-1); i=i-m; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -10,12 +10,11 @@ static double doublePair[2]; void printdoublearray(double* array, int size, int focusstart, int focussize, int swapaindex, int swapbindex){ int i; - float delayseconds=1; static double* last = NULL; static int lastSize = -1; bool haveLast = false; - + if(-1==focussize) { focussize=size; @@ -38,20 +37,20 @@ haveLast = true; } -// NSAutoreleasePool* pool =[[NSAutoreleasePool alloc] init]; -// NSDictionary *blackAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor blackColor],NSForegroundColorAttributeName, -// [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; -// -// NSDictionary *greyAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor grayColor],NSForegroundColorAttributeName, -// [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; -// -// NSDictionary *redAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor redColor],NSForegroundColorAttributeName, -// [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; -// -// NSDictionary *blueAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor blueColor],NSForegroundColorAttributeName, -// [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; -// -// NSAttributedString *myString; + // NSAutoreleasePool* pool =[[NSAutoreleasePool alloc] init]; + // NSDictionary *blackAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor blackColor],NSForegroundColorAttributeName, + // [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; + // + // NSDictionary *greyAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor grayColor],NSForegroundColorAttributeName, + // [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; + // + // NSDictionary *redAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor redColor],NSForegroundColorAttributeName, + // [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; + // + // NSDictionary *blueAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor blueColor],NSForegroundColorAttributeName, + // [NSFont fontWithName:@"Courier" size:10.0],NSFontAttributeName,nil]; + // + // NSAttributedString *myString; char myString[64]; for(i=0; i<size; i++) { @@ -66,42 +65,50 @@ //save last[i] = array[i]; sprintf(myString," %4.0f",array[i]); -// myString = [[NSAttributedString alloc] -// initWithString:[NSString stringWithFormat:@" %4.0f",array[i]] -// attributes: changed?redAttrs: -// (i==swapaindex||i==swapbindex)?blueAttrs: -// (i>=focusstart && i < focusstart+focussize)?blackAttrs:greyAttrs]; + // myString = [[NSAttributedString alloc] + // initWithString:[NSString stringWithFormat:@" %4.0f",array[i]] + // attributes: changed?redAttrs: + // (i==swapaindex||i==swapbindex)?blueAttrs: + // (i>=focusstart && i < focusstart+focussize)?blackAttrs:greyAttrs]; SortingMan::Instance()->AppendToOutput(myString); -// [myString autorelease]; + // [myString autorelease]; } - + sprintf(myString,"\n"); -// myString = [[NSAttributedString alloc] -// initWithString:[NSString stringWithFormat:@"\n"] -// attributes: blackAttrs]; + // myString = [[NSAttributedString alloc] + // initWithString:[NSString stringWithFormat:@"\n"] + // attributes: blackAttrs]; SortingMan::Instance()->AppendToOutput(myString); -// [myString autorelease]; -// [pool release]; - + // [myString autorelease]; + // [pool release]; + float secondsToRest; if(swapaindex!=-1 && swapbindex !=-1) { - //if we were given a pair, we just play the pair. - doublePair[0]=array[swapaindex]; - doublePair[1]=array[swapbindex]; - secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 2, delayseconds); // - }else if(swapaindex!=-1) - { - //some cases have just one number in focus - doublePair[0]=array[swapaindex]; - secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 1, delayseconds); // - }else - secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray(array+focusstart, focussize, delayseconds); // - usleep(1000000*(secondsToRest)); + //if we were given a pair, we just play the pair. + doublePair[0]=array[swapaindex]; + doublePair[1]=array[swapbindex]; + secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 2); // + }else if(swapaindex!=-1) + { + //some cases have just one number in focus + doublePair[0]=array[swapaindex]; + secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 1); // + }else + { + // play the values (freq) of a block + secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray(array+focusstart, focussize); // + } + usleep(1000000*(secondsToRest)); } +void printseperator(int depth) +{ + AlgorhythmicAudioIO::Instance()->PlaySeperator(depth); +} + void printintarray(int* array, int size){ int i; float delayseconds=1; Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.h =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.h 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/sorthelp.h 2010-07-02 11:58:28 UTC (rev 217) @@ -2,4 +2,6 @@ void printintarray(int* array, int size); void fillIntArray(int* array, int size, int minval = -100, int maxval = 100); -void fillDoubleArray(double* array, int size, double minval = -100, double maxval = 100); \ No newline at end of file +void fillDoubleArray(double* array, int size, double minval = -100, double maxval = 100); + +void printseperator(int depth); Modified: algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp =================================================================== --- algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-06-22 21:56:34 UTC (rev 216) +++ algorhythmicSorting/ofAlgorhythmicSorting/src/testApp.cpp 2010-07-02 11:58:28 UTC (rev 217) @@ -17,7 +17,7 @@ arrayFont.setLineHeight(10.0f); ofBackground(255,255,255); - speedSliderVal = speedSliderVal_old = 200; + speedSliderVal = speedSliderVal_old = 25; gui.addTitle("A group"); gui.addSlider("speed", speedSliderVal, 0.01, 1000); gui.addSlider("myInt1", myInt1, 5, 10); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-06-22 21:56:40
|
Revision: 216 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=216&view=rev Author: mchinen Date: 2010-06-22 21:56:34 +0000 (Tue, 22 Jun 2010) Log Message: ----------- diff sep version - longer notes, and no sudden clip (envelope fade in of 20 samples) Modified Paths: -------------- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp Modified: algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp 2010-06-21 21:53:38 UTC (rev 215) +++ algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp 2010-06-22 21:56:34 UTC (rev 216) @@ -33,7 +33,7 @@ //actual desired params float nb_freq =1000; -float nb_bw = 0.99; +float nb_bw = 0.90; float nb_phase = 0.0; float nb_amp = 0.5; @@ -180,7 +180,7 @@ if(!dataa->seperatorPlayed) { click = true; - nb_samples_left = nb_samples_total = dataa->duration * SAMPLE_RATE/8; + nb_samples_left = nb_samples_total = dataa->duration * SAMPLE_RATE; dataa->seperatorPlayed=true; } @@ -206,12 +206,17 @@ } if(sepOn && nb_samples_left) { - nb_freq = 10000/(dataa->seperatorDepth + 1); + nb_freq = 50*powf(2, 1.0+ 19*(dataa->seperatorDepth)/12.0); NoiseBandFillFrame((float*) outputBuffer, framesPerBuffer, vol); for(int i=0;i<framesPerBuffer;i++) { - ((float*)outputBuffer)[i*2] *= (float)nb_samples_left/nb_samples_total; - ((float*)outputBuffer)[i*2+1] *= (float)nb_samples_left/nb_samples_total; + float fade; + //give an upwards fade in of 20 samples if possible + fade = nb_samples_total>40?(nb_samples_total-nb_samples_left<20?((float)nb_samples_total-nb_samples_left)/20.0 + :((float)(nb_samples_left-20)/nb_samples_total) ) + :((float)nb_samples_left/nb_samples_total); + ((float*)outputBuffer)[i*2] *= fade; + ((float*)outputBuffer)[i*2+1] *= fade; if(nb_samples_left>0) nb_samples_left--; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-06-21 21:53:44
|
Revision: 215 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=215&view=rev Author: mchinen Date: 2010-06-21 21:53:38 +0000 (Mon, 21 Jun 2010) Log Message: ----------- making percussive noiseband. Also fixing quicksort sonification to sonify a while loop. Modified Paths: -------------- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp algorhythmicSorting/found_algorithms/heap.cpp algorhythmicSorting/found_algorithms/insert.cpp algorhythmicSorting/found_algorithms/shell.cpp algorhythmicSorting/sortingGUI/cleanerinsert.cpp algorhythmicSorting/sortingGUI/quicksort.cpp algorhythmicSorting/sortingGUI/select.cpp algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj Modified: algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -33,7 +33,7 @@ //actual desired params float nb_freq =1000; -float nb_bw = 0.5; +float nb_bw = 0.99; float nb_phase = 0.0; float nb_amp = 0.5; @@ -140,7 +140,8 @@ } - +int nb_samples_left = 0; +int nb_samples_total = 0; /* This routine will be called by the PortAudio engine when audio is needed. ** It may called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). @@ -179,6 +180,7 @@ if(!dataa->seperatorPlayed) { click = true; + nb_samples_left = nb_samples_total = dataa->duration * SAMPLE_RATE/8; dataa->seperatorPlayed=true; } @@ -202,14 +204,27 @@ freq = freqRange*exp2cursor(freq/20000.0)+freqMin; pan = ((float)index)/dataa->doubleArraySize; } + + if(sepOn && nb_samples_left) { + nb_freq = 10000/(dataa->seperatorDepth + 1); + + NoiseBandFillFrame((float*) outputBuffer, framesPerBuffer, vol); + for(int i=0;i<framesPerBuffer;i++) { + ((float*)outputBuffer)[i*2] *= (float)nb_samples_left/nb_samples_total; + ((float*)outputBuffer)[i*2+1] *= (float)nb_samples_left/nb_samples_total; + if(nb_samples_left>0) + nb_samples_left--; + } + } + for(unsigned int i = 0; i < framesPerBuffer*NUM_CHANNELS; i+=2) { float sinval; sinval = sin(dataa->phase); - if(notesOn || (index == dataa->doubleArraySize && sepOn )) + if(notesOn)//old sep || (index == dataa->doubleArraySize && sepOn )) { - ((float*)outputBuffer)[i] = sinval * (1.0-pan) * vol * 0.5; - ((float*)outputBuffer)[i+1] = sinval * pan * vol * 0.5; + ((float*)outputBuffer)[i] += sinval * (1.0-pan) * vol * 0.5; + ((float*)outputBuffer)[i+1] += sinval * pan * vol * 0.5; } if(1 || click) { float bassmult = 16*dataa->seperatorDepth+1; @@ -251,11 +266,7 @@ } } - if(sepOn) { - nb_freq = (dataa->seperatorDepth + 1)*400; - - NoiseBandFillFrame((float*) outputBuffer, framesPerBuffer, vol); - } + } AlgorhythmicAudioIO::Instance()->unLockSortData(); @@ -316,7 +327,7 @@ mzsortdata.lastNoteIndex=0; mzsortdata.durationsSize=0; mzsortdata.seperatorDepth = 0; - mzsortdata.seperatorPlayed = false;; + mzsortdata.seperatorPlayed = true; /* Initialize library before making any other calls. */ err = Pa_Initialize(); @@ -351,14 +362,13 @@ mzsortdata.seperatorPlayed = false; } -float AlgorhythmicAudioIO::PlayDoubleArray(double * array, int size, float duration)//, int swapaindex, int swapbindex) +float AlgorhythmicAudioIO::PlayDoubleArray(double * array, int size)//, int swapaindex, int swapbindex) { mzsortdata.approxEvals+=size; LockSortData(); mzsortdata.doubleArray=array; mzsortdata.doubleArraySize=size; - mzsortdata.duration=duration; if(mzsortdata.durationsSize<size) { @@ -416,6 +426,9 @@ //duration of break mzsortdata.durations[size] = 0.0;//(m_seperatorOn?1.0:0.0) *m_speed; secDuration += mzsortdata.durations[size]; + + + mzsortdata.duration=secDuration; unLockSortData(); return secDuration; Modified: algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h 2010-06-21 21:53:38 UTC (rev 215) @@ -52,7 +52,7 @@ void PlaySeperator(int depth); void PlayIntArray(int * array, int size, float duration); - float PlayDoubleArray(double * array, int size, float duration); + float PlayDoubleArray(double * array, int size); void ChangeSpeed(float newSpeed){m_speed=newSpeed;} void ToggleSeperator(){m_seperatorOn = !m_seperatorOn;} Modified: algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -43,8 +43,8 @@ for (i=0; i<n; i++) { // counts from 0 to n printseperator(0); for (j=n-1; i<j; j--){ // nested (verschachtelt) forloop | starts at the end of the array, as long i is smaller than j >> as long the end of the array is not reached - if(j!=n-1) - printseperator(1); + //if(j!=n-1) + // printseperator(1); //inner loop happens more // nested loop gives a clue for O(f(n^2)) Modified: algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -13,7 +13,6 @@ void printdoublearray(double* array, int size, int focusstart, int focussize, int swapaindex, int swapbindex){ int i; - float delayseconds=1; static double* last = NULL; static int lastSize = -1; @@ -104,16 +103,16 @@ //if we were given a pair, we just play the pair. doublePair[0]=array[swapaindex]; doublePair[1]=array[swapbindex]; - secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 2, delayseconds); // + secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 2); // }else if(swapaindex!=-1) { //some cases have just one number in focus doublePair[0]=array[swapaindex]; - secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 1, delayseconds); // + secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray((double*)doublePair, 1); // }else { // play the values (freq) of a block - secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray(array+focusstart, focussize, delayseconds); // + secondsToRest = AlgorhythmicAudioIO::Instance()->PlayDoubleArray(array+focusstart, focussize); // } usleep(1000000*(secondsToRest)); } Modified: algorhythmicSorting/found_algorithms/heap.cpp =================================================================== --- algorhythmicSorting/found_algorithms/heap.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/found_algorithms/heap.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -44,12 +44,12 @@ int m= (n + (WIDTH - 2)) / WIDTH; // first leaf in the heap int count= 0; int origchild, orign,origparent; + int depth ; orign= n; while ( 1 ) { - printseperator(0); if ( m ) { // First Part of the Algorithm: Make a max-Heap parent= --m; @@ -67,10 +67,11 @@ origparent=parent; origchild = parent * WIDTH + 1; + depth =1; while ( (child= parent * WIDTH + 1) < n ) // erstes Kind; { // Abbruch am Ende des Heaps - printseperator(1); + printseperator(depth); w= n - child < WIDTH ? n - child : WIDTH; // Anzahl der vorhandenen Geschwister @@ -80,12 +81,12 @@ for ( max= 0, i= 1; i < w; ++i ) // größtes Kind suchen if ( data[child+i] > data[child+max] ) { - printdoublearray(data,orign,0,0, child+1, child+max); + printdoublearray(data,orign,0,0, child+i, child+max); max= i; } else { - printdoublearray(data,orign,0,0, child+1, child+max); + printdoublearray(data,orign,0,0, child+i, child+max); } child += max; @@ -102,11 +103,14 @@ #endif parent= child; // in der Ebene darunter weitersuchen + depth++;//for our print/sonification } data[parent]= val; // versickerten Wert eintragen - if(parent-origchild>0) + if(parent-origchild>0) { + printseperator(0); printdoublearray(data, orign,0,0,parent,-1);//origparent, origchild-origparent); + } } return count; Modified: algorhythmicSorting/found_algorithms/insert.cpp =================================================================== --- algorhythmicSorting/found_algorithms/insert.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/found_algorithms/insert.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -47,11 +47,12 @@ int i,j; double a; for (j=2; j<N+1; j++) { + printseperator(0); a=ARR[j]; for (i=j-1; i>0; i--) { if (ARR[i]<=a) goto e10; ARR[i+1]=ARR[i]; - printseperator(1); +// printseperator(1); printdoublearray(realArray, N,i-1,2,i);//i-1,i); #ifdef SORTING_COCOAGUI if(SortingMan::Instance()->ShouldStop()) @@ -60,8 +61,7 @@ } i=0; - e10: ARR[i+1]=a; - printseperator(0); + e10: ARR[i+1]=a; printdoublearray(realArray, N,i-1,2,i);//i-1,i); Modified: algorhythmicSorting/found_algorithms/shell.cpp =================================================================== --- algorhythmicSorting/found_algorithms/shell.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/found_algorithms/shell.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -57,8 +57,8 @@ for (j=1; j<k+1; j++) { i=j; e10: l=i+m; - if(j!=1) - printseperator(1); + //if(j!=1) + // printseperator(1); if (ARR[l] < ARR[i]) { t=ARR[i]; ARR[i]=ARR[l]; Modified: algorhythmicSorting/sortingGUI/cleanerinsert.cpp =================================================================== --- algorhythmicSorting/sortingGUI/cleanerinsert.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/sortingGUI/cleanerinsert.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -41,7 +41,7 @@ for (j = i - 1; j >= 0; j--) { - printseperator(1); +// printseperator(1); if (a[j] <= v) { printdoublearray(a, length, 0, 0, j, i); // function defined somewhere else Modified: algorhythmicSorting/sortingGUI/quicksort.cpp =================================================================== --- algorhythmicSorting/sortingGUI/quicksort.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/sortingGUI/quicksort.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -22,11 +22,17 @@ do { printseperator(depth); /* find member above ... */ - while(arr[i] < z) i++; + while(arr[i] < z) { + printdoublearray(arr,orign,0,0, i, (low+high)/2); + i++; + } /* find element below ... */ - while(arr[j] > z) j--; - + while(arr[j] > z) { + printdoublearray(arr,orign,0,0, j, (low+high)/2); + j--; + } + if(i <= j) { /* swap two elements */ y = arr[i]; Modified: algorhythmicSorting/sortingGUI/select.cpp =================================================================== --- algorhythmicSorting/sortingGUI/select.cpp 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/sortingGUI/select.cpp 2010-06-21 21:53:38 UTC (rev 215) @@ -20,8 +20,8 @@ smallestvalue = 100000; // smallestvalue found so far > used to compare with values of array > gets reset for each i-interation for (int j=i; j<sizeofarray; j++) { // this forloop starts at i and counts from there to the end of extarray - if(j!=i) - printseperator(1); +// if(j!=i) +// printseperator(1); printdoublearray(extrarray, sizeofarray, 0, 0, j, smallestindex); // function defined somewhere else if (smallestvalue > extrarray[j]){ Modified: algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj =================================================================== --- algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj 2010-06-20 19:39:27 UTC (rev 214) +++ algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj 2010-06-21 21:53:38 UTC (rev 215) @@ -376,6 +376,7 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_OPTIMIZATION_LEVEL = 0; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mc...@us...> - 2010-06-20 19:39:33
|
Revision: 214 http://algorhythmics.svn.sourceforge.net/algorhythmics/?rev=214&view=rev Author: mchinen Date: 2010-06-20 19:39:27 +0000 (Sun, 20 Jun 2010) Log Message: ----------- new type of seperator Modified Paths: -------------- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp algorhythmicSorting/algoRhythmicSortingCommandline/msort.cpp algorhythmicSorting/algoRhythmicSortingCommandline/msort.h algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.h algorhythmicSorting/found_algorithms/heap.cpp algorhythmicSorting/found_algorithms/insert.cpp algorhythmicSorting/found_algorithms/shell.cpp algorhythmicSorting/sortingGUI/SortingMan.cpp algorhythmicSorting/sortingGUI/cleanerinsert.cpp algorhythmicSorting/sortingGUI/quicksort.cpp algorhythmicSorting/sortingGUI/select.cpp algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj Modified: algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -31,6 +31,116 @@ static paTestData data; static bool gManagerCreated = false; +//actual desired params +float nb_freq =1000; +float nb_bw = 0.5; +float nb_phase = 0.0; +float nb_amp = 0.5; + + //for real time state keeping + bool laston; + float lastfreq; + float lastamp; + float lastbw; + float instfreq; + float phase; + float targetfreq; + int samplesTillNextTarget; + bool initedForRealTime = false; + + +//generate a block the size of the buffer. +void NoiseBandFillFrame(float* buf, int length, float vol) +{ + if(!initedForRealTime) + { + + laston = false; + lastfreq = nb_freq; + lastamp = 0.0; + lastbw = nb_bw; + instfreq = nb_freq; + targetfreq = nb_freq; + + phase = nb_phase; + samplesTillNextTarget=0; + initedForRealTime = true; + } + + + double phaseAdd; + bool on = true; + float amp = lastamp; + + float freq = lastfreq; + float bw =lastbw; + //for quick ref + + float curamp; + float curfreq; + float curbw; + + curamp = nb_amp; + curfreq = nb_freq; + curbw = nb_bw; + + + laston = on; + + if(on||laston) + { + for(int j = 0 ; j<length ; j++ ) + { + + bw = curbw;//curpg->Interpolate(3,lastbw,curbw,length==0?1.0:(float)j/(float)length,bwFormat); + freq = curfreq;//curpg->Interpolate(1,lastfreq,curfreq,length==0?1.0:(float)j/(float)length,freqFormat); + amp = curamp;//curpg->Interpolate(0,lastamp,on?curamp:0.0,length==0?1.0:(float)j/(float)length,ampFormat); + + + //see if we need a new target + if(samplesTillNextTarget <0) + { + targetfreq = randfloat(freq*bw*2.0)+freq*(1.0-bw); //assumes bw <1.0 + samplesTillNextTarget = randint(44100/mymax(2.0,freq))+1.0; + }else + { + samplesTillNextTarget--; + } + + instfreq = instfreq + (targetfreq-instfreq)/mymax(1.0,samplesTillNextTarget); + + phaseAdd = instfreq*2.0*3.141592/44100.0; + //phaseAdd += phaseAdd* (randfloat(bw*2)-bw); + + phase += phaseAdd; + while(phase>2.0*3.141592) + phase-=2.0*3.141592; + + buf[j*2]+=amp*sin(phase) *vol; + buf[j*2+1]+=amp*sin(phase) * vol; + + + } + }else + { + //advance phase, but try not to loose precision with a large to small addition. + phaseAdd = length*freq*2.0*3.141592/44100.0; + while(phaseAdd>2.0*3.141592) + phaseAdd-=2.0*3.141592; + + phase += phaseAdd; + while(phase>2.0*3.141592) + phase-=2.0*3.141592; + } + + lastamp = amp; + lastfreq = freq; + lastbw = bw; + +} + + + /* This routine will be called by the PortAudio engine when audio is needed. ** It may called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). @@ -49,6 +159,8 @@ float freqMin = AlgorhythmicAudioIO::Instance()->GetFreqMin(); float freqRange = AlgorhythmicAudioIO::Instance()->GetFreqMax() - freqMin; bool notesOn = AlgorhythmicAudioIO::Instance()->IsNotesOn(); + bool sepOn = AlgorhythmicAudioIO::Instance()->IsSeperatorOn(); + bool click = false; for( int z = 0; z < NUM_CHANNELS; z++ ) memset(((float*)outputBuffer)+framesPerBuffer*z, 0, framesPerBuffer*sizeof(float)); @@ -62,6 +174,14 @@ if(dataa->usedouble) { AlgorhythmicAudioIO::Instance()->LockSortData(); + + //if this is a fresh array + if(!dataa->seperatorPlayed) + { + click = true; + dataa->seperatorPlayed=true; + } + //double array. //duration is for the entire array. //get the index of the number we are interested in by looking at how much we've played back so far. @@ -86,11 +206,16 @@ { float sinval; sinval = sin(dataa->phase); - if(notesOn || index == dataa->doubleArraySize) + if(notesOn || (index == dataa->doubleArraySize && sepOn )) { - ((float*)outputBuffer)[i] = sinval * (1.0-pan) * vol; - ((float*)outputBuffer)[i+1] = sinval * pan * vol; + ((float*)outputBuffer)[i] = sinval * (1.0-pan) * vol * 0.5; + ((float*)outputBuffer)[i+1] = sinval * pan * vol * 0.5; } + if(1 || click) { + float bassmult = 16*dataa->seperatorDepth+1; +// ((float*)outputBuffer)[i] += vol*2*((float)mymax(0,(framesPerBuffer*NUM_CHANNELS-(i*bassmult)))/framesPerBuffer*NUM_CHANNELS); +// ((float*)outputBuffer)[i+1] += vol*2*((float)mymax(0,(framesPerBuffer*NUM_CHANNELS-(i*bassmult)))/framesPerBuffer*NUM_CHANNELS); + } //inc phase if we are under the size, otherwise use noise. if(index < dataa->doubleArraySize) { @@ -126,6 +251,11 @@ } } + if(sepOn) { + nb_freq = (dataa->seperatorDepth + 1)*400; + + NoiseBandFillFrame((float*) outputBuffer, framesPerBuffer, vol); + } } AlgorhythmicAudioIO::Instance()->unLockSortData(); @@ -185,6 +315,8 @@ mzsortdata.durations = NULL; mzsortdata.lastNoteIndex=0; mzsortdata.durationsSize=0; + mzsortdata.seperatorDepth = 0; + mzsortdata.seperatorPlayed = false;; /* Initialize library before making any other calls. */ err = Pa_Initialize(); @@ -214,6 +346,10 @@ { [audioDataMutex unlock]; } +void AlgorhythmicAudioIO::PlaySeperator(int depth){ + mzsortdata.seperatorDepth = depth; + mzsortdata.seperatorPlayed = false; +} float AlgorhythmicAudioIO::PlayDoubleArray(double * array, int size, float duration)//, int swapaindex, int swapbindex) { @@ -278,7 +414,7 @@ secDuration += mzsortdata.durations[i]; } //duration of break - mzsortdata.durations[size] = (m_seperatorOn?1.0:0.0) *m_speed; + mzsortdata.durations[size] = 0.0;//(m_seperatorOn?1.0:0.0) *m_speed; secDuration += mzsortdata.durations[size]; unLockSortData(); Modified: algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/AlgorhythmicAudioIO.h 2010-06-20 19:39:27 UTC (rev 214) @@ -30,6 +30,9 @@ int lastNoteIndex; int approxEvals; + + int seperatorDepth; + bool seperatorPlayed; }; class AlgorhythmicAudioIO @@ -47,6 +50,7 @@ float GetSpeed(){return m_speed;} + void PlaySeperator(int depth); void PlayIntArray(int * array, int size, float duration); float PlayDoubleArray(double * array, int size, float duration); void ChangeSpeed(float newSpeed){m_speed=newSpeed;} @@ -62,6 +66,7 @@ float GetVolume(){return m_volume;} bool IsNotesOn(){return m_notesOn;} + bool IsSeperatorOn(){return m_seperatorOn;} float GetFreqMin(){return m_freqMin;} float GetFreqMax(){return m_freqMax;} Modified: algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/bubble.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -41,9 +41,11 @@ int i,j; for (i=0; i<n; i++) { // counts from 0 to n - + printseperator(0); for (j=n-1; i<j; j--){ // nested (verschachtelt) forloop | starts at the end of the array, as long i is smaller than j >> as long the end of the array is not reached - //inner loop happens more + if(j!=n-1) + printseperator(1); + //inner loop happens more // nested loop gives a clue for O(f(n^2)) Order(&something[j-1], &something[j]); // call function "order". first look and "Order" the last two values of array and then decrement (j--) until i (beginning of array) Modified: algorhythmicSorting/algoRhythmicSortingCommandline/msort.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/msort.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/msort.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -36,7 +36,7 @@ // and then 4 and then 8 etc. There is natural merge sorts and inplace mergesorts. Natural mergesort uses more arrays. -void sort(double *a, int lo, int hi, bool toplevel) { // lo=0, hi=n-1 (only for the first call) +void sort(double *a, int lo, int hi, int depth ) { // lo=0, hi=n-1 (only for the first call) // lo and hi are index static double* original; @@ -47,7 +47,7 @@ return; #endif - if(toplevel){ + if(depth==0){ original = a; originalsize = hi+1; @@ -62,11 +62,10 @@ // Recursion breaks up the array in to smaller pieces before they are going to be sorted! // Partition the list into two lists and sort them recursively - sort(a, lo, mid, false); // compare with void sort(double *a, int lo, int hi, bool toplevel) - sort(a, mid + 1, hi, false); + sort(a, lo, mid, depth+1); // compare with void sort(double *a, int lo, int hi, bool toplevel) + sort(a, mid + 1, hi, depth+1); - // Merge the two sorted lists int start_hi = mid + 1; int end_lo = mid; @@ -74,6 +73,7 @@ // [2,3] [5,4] [0,5] [4,6] >> 2 at index 3, 5 at index 4 ... // code which is run on each piece of the whole array while ((lo <= end_lo) && (start_hi <= hi)) { + printseperator(depth); if (a[lo] < a[start_hi]) // if value of array a at index lo is smaller value at start-hi Modified: algorhythmicSorting/algoRhythmicSortingCommandline/msort.h =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/msort.h 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/msort.h 2010-06-20 19:39:27 UTC (rev 214) @@ -7,4 +7,4 @@ * */ -void sort(double *a, int lo, int hi, bool toplevel=true); +void sort(double *a, int lo, int hi, int depth = 0); Modified: algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -118,6 +118,11 @@ usleep(1000000*(secondsToRest)); } +void printseperator(int depth) +{ + AlgorhythmicAudioIO::Instance()->PlaySeperator(depth); +} + void printintarray(int* array, int size){ int i; float delayseconds=1; Modified: algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.h =================================================================== --- algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.h 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/algoRhythmicSortingCommandline/sorthelp.h 2010-06-20 19:39:27 UTC (rev 214) @@ -2,4 +2,6 @@ void printintarray(int* array, int size); void fillIntArray(int* array, int size, int minval = -100, int maxval = 100); -void fillDoubleArray(double* array, int size, double minval = -100, double maxval = 100); \ No newline at end of file +void fillDoubleArray(double* array, int size, double minval = -100, double maxval = 100); + +void printseperator(int depth); Modified: algorhythmicSorting/found_algorithms/heap.cpp =================================================================== --- algorhythmicSorting/found_algorithms/heap.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/found_algorithms/heap.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -48,6 +48,8 @@ while ( 1 ) { + + printseperator(0); if ( m ) { // First Part of the Algorithm: Make a max-Heap parent= --m; @@ -68,6 +70,7 @@ while ( (child= parent * WIDTH + 1) < n ) // erstes Kind; { // Abbruch am Ende des Heaps + printseperator(1); w= n - child < WIDTH ? n - child : WIDTH; // Anzahl der vorhandenen Geschwister Modified: algorhythmicSorting/found_algorithms/insert.cpp =================================================================== --- algorhythmicSorting/found_algorithms/insert.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/found_algorithms/insert.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -1,80 +1,82 @@ /************************************************** -* Sorting an array with straight insertion method * -* ----------------------------------------------- * -* REFERENCE: * -* * -* "NUMERICAL RECIPES By W.H. Press, B.P. Flannery,* -* S.A. Teukolsky and W.T. Vetterling, Cambridge * -* University Press, 1986" [BIBLI 08]. * -* * -* C++ version by J-P Moreau * - -**************************************************/ + * Sorting an array with straight insertion method * + * ----------------------------------------------- * + * REFERENCE: * + * * + * "NUMERICAL RECIPES By W.H. Press, B.P. Flannery,* + * S.A. Teukolsky and W.T. Vetterling, Cambridge * + * University Press, 1986" [BIBLI 08]. * + * * + * C++ version by J-P Moreau * + + **************************************************/ #include <stdio.h> #include <stdlib.h> #include <math.h> #include "sorthelp.h" #ifdef SORTING_COCOAGUI - #include "SortingMan.h" +#include "SortingMan.h" #endif /**************************************************** -* Sorts an array ARR of length N in ascending order * -* by straight insertion. * -* ------------------------------------------------- * -* INPUTS: * -* N size of table ARR * -* ARR table to be sorted * -* OUTPUT: * -* ARR table sorted in ascending order * -* * -* NOTE: Straight insertion is a N≤ routine and * -* should only be used for relatively small * -* arrays (N<100). * -****************************************************/ + * Sorts an array ARR of length N in ascending order * + * by straight insertion. * + * ------------------------------------------------- * + * INPUTS: * + * N size of table ARR * + * ARR table to be sorted * + * OUTPUT: * + * ARR table sorted in ascending order * + * * + * NOTE: Straight insertion is a N≤ routine and * + * should only be used for relatively small * + * arrays (N<100). * + ****************************************************/ void PIKSRT(int N, double *ARR) { -//Label: e10 + //Label: e10 double* realArray=ARR; //SORTING stupid but this algorithm starts counding at 1, not zero, so this is a hack. ARR--; - - int i,j; double a; - for (j=2; j<N+1; j++) { - a=ARR[j]; - for (i=j-1; i>0; i--) { - if (ARR[i]<=a) goto e10; - ARR[i+1]=ARR[i]; - printdoublearray(realArray, N,i-1,2,i);//i-1,i); + + int i,j; double a; + for (j=2; j<N+1; j++) { + a=ARR[j]; + for (i=j-1; i>0; i--) { + if (ARR[i]<=a) goto e10; + ARR[i+1]=ARR[i]; + printseperator(1); + printdoublearray(realArray, N,i-1,2,i);//i-1,i); #ifdef SORTING_COCOAGUI if(SortingMan::Instance()->ShouldStop()) return; #endif - - } - i=0; -e10: ARR[i+1]=a; - - printdoublearray(realArray, N,i-1,2,i);//i-1,i); - - } + + } + i=0; + e10: ARR[i+1]=a; + printseperator(0); + + printdoublearray(realArray, N,i-1,2,i);//i-1,i); + + } } //write table of size N to standard output void TWRIT(int N, double *ARR) { - int i; float tmp; - printf("\n");; - for (i=1; i<N+1; i++) { - tmp=ARR[i]; - printf(" %6.0f",tmp); - if ((i % 5)==0) printf("\n"); - } + int i; float tmp; + printf("\n");; + for (i=1; i<N+1; i++) { + tmp=ARR[i]; + printf(" %6.0f",tmp); + if ((i % 5)==0) printf("\n"); + } } Modified: algorhythmicSorting/found_algorithms/shell.cpp =================================================================== --- algorhythmicSorting/found_algorithms/shell.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/found_algorithms/shell.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -51,11 +51,14 @@ LOGNB2=(double) floor(log(n)*ALN2I+TINY); m=n; for (nn=1; nn<=floor(LOGNB2); nn++) { + printseperator(0); m=m / 2; k=n-m; for (j=1; j<k+1; j++) { i=j; e10: l=i+m; + if(j!=1) + printseperator(1); if (ARR[l] < ARR[i]) { t=ARR[i]; ARR[i]=ARR[l]; Modified: algorhythmicSorting/sortingGUI/SortingMan.cpp =================================================================== --- algorhythmicSorting/sortingGUI/SortingMan.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/sortingGUI/SortingMan.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -173,7 +173,7 @@ void Order(double* p,double* q); void Bubble(double* something,int n); //bubble sort -void sort(double *a, int lo, int hi, bool toplevel=true); //merge sort +void sort(double *a, int lo, int hi, int depth = 0);//merge sort void dobubblesort (sort_params* params) { //printdoublearray(params->array, params->size); Modified: algorhythmicSorting/sortingGUI/cleanerinsert.cpp =================================================================== --- algorhythmicSorting/sortingGUI/cleanerinsert.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/sortingGUI/cleanerinsert.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -41,6 +41,7 @@ for (j = i - 1; j >= 0; j--) { + printseperator(1); if (a[j] <= v) { printdoublearray(a, length, 0, 0, j, i); // function defined somewhere else @@ -57,6 +58,7 @@ #endif } a[j + 1] = v; + printseperator(0); printdoublearray(a, length, 0, 0, j+1, i); // function defined somewhere else Modified: algorhythmicSorting/sortingGUI/quicksort.cpp =================================================================== --- algorhythmicSorting/sortingGUI/quicksort.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/sortingGUI/quicksort.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -1,6 +1,6 @@ #include "sorthelp.h" -void quicksort_helper(double arr[], int low, int high) ; +void quicksort_helper(double arr[], int low, int high, int depth =0) ; /* sort everything inbetween `low' <-> `high' */ int orign; @@ -11,7 +11,7 @@ quicksort_helper(arr,0,n-1); } -void quicksort_helper(double arr[], int low, int high) { +void quicksort_helper(double arr[], int low, int high, int depth) { int i = low; int j = high; double y = 0; @@ -20,6 +20,7 @@ /* partition */ do { + printseperator(depth); /* find member above ... */ while(arr[i] < z) i++; @@ -43,8 +44,8 @@ /* recurse */ if(low < j) - quicksort_helper(arr, low, j); + quicksort_helper(arr, low, j,depth+1); if(i < high) - quicksort_helper(arr, i, high); + quicksort_helper(arr, i, high,depth+1); } Modified: algorhythmicSorting/sortingGUI/select.cpp =================================================================== --- algorhythmicSorting/sortingGUI/select.cpp 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/sortingGUI/select.cpp 2010-06-20 19:39:27 UTC (rev 214) @@ -16,18 +16,20 @@ double smallestvalue; for (int i=0; i<sizeofarray; i++) { + printseperator(0); smallestvalue = 100000; // smallestvalue found so far > used to compare with values of array > gets reset for each i-interation for (int j=i; j<sizeofarray; j++) { // this forloop starts at i and counts from there to the end of extarray - + if(j!=i) + printseperator(1); printdoublearray(extrarray, sizeofarray, 0, 0, j, smallestindex); // function defined somewhere else if (smallestvalue > extrarray[j]){ smallestvalue = extrarray[j]; // swap if intitial value is bigger than value to compare smallestindex = j; //save the index value of the smallest value found so far } - -// stopping the loop + + // stopping the loop #ifdef SORTING_COCOAGUI if(SortingMan::Instance()->ShouldStop()) return; @@ -42,7 +44,7 @@ printdoublearray(extrarray, sizeofarray, 0, 0, i, smallestindex); // function defined somewhere else } - + } Modified: algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj =================================================================== --- algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj 2010-06-20 17:30:29 UTC (rev 213) +++ algorhythmicSorting/sortingGUI/sortingGUI.xcodeproj/project.pbxproj 2010-06-20 19:39:27 UTC (rev 214) @@ -179,8 +179,8 @@ 84C6F1E2118DD2FE00C723F6 /* libportaudio.a */, 84C6F1E3118DD2FE00C723F6 /* msort.cpp */, 84C6F1E5118DD2FE00C723F6 /* sorthelp.cpp */, + 32CA4F630368D1EE00C91783 /* sortingGUI_Prefix.pch */, 84C6F1E6118DD2FE00C723F6 /* sorthelp.h */, - 32CA4F630368D1EE00C91783 /* sortingGUI_Prefix.pch */, 29B97316FDCFA39411CA2CEA /* main.m */, 84BE59FC11A6EE000092BDA7 /* quicksort.cpp */, 3EF0FCDB11C5214800DBA10A /* select.cpp */, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |