• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Mac OS Xのmake環境でOpenFrameworksプロジェクト作成できるように整備したもの


Commit MetaInfo

Révisionaa3d9e7097f7cb5c960371ffffc6c675762267d7 (tree)
l'heure2013-09-29 19:56:58
Auteursambuichi <sambuichi@gmai...>
Commitersambuichi

Message de Log

remove abondoned app source code.

Change Summary

  • delete: myprj/pictMove/Makefile
  • delete: myprj/pictMove/main.cpp
  • delete: myprj/pictMove/ofxQtVideoSaver.cpp
  • delete: myprj/pictMove/ofxQtVideoSaver.h
  • delete: myprj/pictMove/testApp.cpp
  • delete: myprj/pictMove/testApp.h
  • delete: myprj/rtaudioTest/Makefile
  • delete: myprj/rtaudioTest/main.cpp
  • delete: myprj/test/Makefile
  • delete: myprj/test/main.cpp
  • delete: myprj/test/testApp.cpp
  • delete: myprj/test/testApp.h

Modification

--- a/myprj/pictMove/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
1-#-------------------------------------------------------------------------------
2-# of_preRelease_v007_osx向けMakefile
3-#
4-# + of_preRelease_v007_osx.zipを展開する
5-# + MakefileのOF_PATHをof_preRelease_v007_osx.zip展開した場所
6-# + libs/fmodex/lib/osx/libfmodex.dylibは実行前に/usr/libとかへコピーしとく
7-#-------------------------------------------------------------------------------
8-CC = gcc -arch i386
9-CPP = g++ -arch i386
10-CFLAGS = -g -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
11-CFLAGS += -DMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.6.sdk/ -DMAKE_OSX_DEPLOYMENT_TARGET=10.6
12-LDFLAGS = -L/usr/local/lib
13-LIBS = -lm
14-DEST = /usr/local/bin
15-OBJS = main.o testApp.o ofxQtVideoSaver.o
16-PROGRAM = run
17-
18-MACOSX_DEPLOYMENT_TARGET=10.7
19-
20-#cmake -G "Unix Makefiles" -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.7.sdk/ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 ../..
21-
22-# openframeworkの共通定義をインクルード
23-include ../Makefile-of.mk
24-
25-# サフィックスルール適用対象の拡張子の定義
26-.SUFFIXES: .c .cpp .o
27-
28-# サフィックスルール
29-.c.o:
30- $(CC) $(CFLAGS) $(OF_CORE_HEADERS) -c $<
31-
32-.cpp.o:
33- $(CPP) $(CFLAGS) $(OF_CORE_HEADERS) -c $<
34-
35-all: $(PROGRAM)
36-
37-$(PROGRAM): $(OBJS)
38- $(CPP) $(LDFLAGS) $(LIBS) $(OF_LINK) $(OBJS) -o $(PROGRAM)
39- chmod 755 $(PROGRAM)
40-
41-clean:; rm -f *.o *~ $(PROGRAM)
42-
43-install: $(PROGRAM)
44- install -s $(PROGRAM) $(DEST)
--- a/myprj/pictMove/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
1-#include <stdio.h>
2-#include <math.h>
3-#include <iostream>
4-
5-#include "ofMain.h"
6-#include "testApp.h"
7-#include "ofAppGlutWindow.h"
8-
9-int main(int argc, char *argv[])
10-{
11- printf("OF Lib project pictMove\n");
12-
13- ofAppGlutWindow window;
14- ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
15-
16- // this kicks off the running of my app
17- // can be OF_WINDOW or OF_FULLSCREEN
18- // pass in width and height too:
19- ofRunApp( new testApp());
20-}
21-
22-
23-
--- a/myprj/pictMove/ofxQtVideoSaver.cpp
+++ /dev/null
@@ -1,554 +0,0 @@
1-#include "ofxQtVideoSaver.h"
2-
3-ofxQtVideoSaver::ofxQtVideoSaver (){
4- sResRefNum = 0;
5- movie = nil;
6- track = NULL;
7- media = NULL;
8- pMovieGWorld = NULL;
9- pixMapHandle = NULL;
10- pCompressedData = NULL;
11- pSavedPort = NULL;
12- hSavedDevice = NULL;
13- hCompressedData = NULL;
14- lMaxCompressionSize = 0L;
15- hImageDescription = NULL;
16- codecType = kJPEGCodecType;
17- codecQualityLevel = OF_QT_SAVER_CODEC_QUALITY_HIGH;
18- bSetupForRecordingMovie = false;
19-}
20-
21-
22-void ofxQtVideoSaver::setCodecQualityLevel(int level) {
23- if (level <= OF_QT_SAVER_CODEC_QUALITY_LOSSLESS && level >= 0){
24- codecQualityLevel = level;
25- } else {
26- printf("please see the defines in ofQtSaver.h \n");
27- }
28-}
29-
30-
31-void ofxQtVideoSaver::setup( int width , int height, string movieName){
32-
33- w = width;
34- h = height;
35-
36-
37- //fileName = (ofToDataPath(movieName));
38- fileName = movieName;
39- //pszFlatFilename = flatFileName;
40-
41- initializeQuicktime();
42- /* Load the FSSpec structure to describe the receiving file. For a
43- description of this and related calls see
44- http://developer.apple.com/quicktime/icefloe/dispatch004.html.
45- ================================================================ */
46-
47-
48- #ifdef TARGET_WIN32
49- FILE * pFile;
50- pFile = fopen (fileName.c_str(),"w");
51- fclose (pFile);
52- char fileNameStr[255];
53- sprintf(fileNameStr, "%s", fileName.c_str());
54- osErr = NativePathNameToFSSpec (fileNameStr, &fsSpec, 0);
55-
56- #endif
57- #ifdef TARGET_OSX
58-
59- /// kill a file and make a new one if needed:
60- FILE * pFile;
61- pFile = fopen (fileName.c_str(),"w");
62- fclose (pFile);
63-
64- Boolean isdir;
65- osErr = FSPathMakeRef((const UInt8*)fileName.c_str(), &fsref, &isdir);
66- osErr = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL);
67- #endif
68-
69- if (osErr && (osErr != fnfErr)) /* File-not-found error is ok */
70- {
71- printf ("getting FSS spec failed %d\n", osErr);
72- goto bail;
73- }
74-
75-
76- /* Step 1: Create a new, empty movie file and a movie that references that
77- file (CreateMovieFile).
78- ======================================================================== */
79-
80- osErr = CreateMovieFile
81- (
82- &fsSpec, /* FSSpec specifier */
83- FOUR_CHAR_CODE('TVOD'), /* file creator type, TVOD = QT player*/
84- smCurrentScript, /* movie script system to use */
85- createMovieFileDeleteCurFile /* movie file creation flags */
86- | createMovieFileDontCreateResFile,
87- &sResRefNum, /* returned file ref num to data fork */
88- &movie /* returned handle to open empty movie*/
89- /* that references the created file */
90- );
91- if (osErr)
92- {
93- printf ("CreateMovieFile failed %d\n", osErr);
94- goto bail;
95- }
96-
97-
98- /* Step 2: Add a new track to that movie (NewMovieTrack).
99- ======================================================= */
100-
101- track = NewMovieTrack
102- (
103- movie, /* the movie to add track to */
104- ((long) w << 16), /* width of track in pixels (Fixed) */
105- FixRatio (h, 1), /* height of track in pixels (Fixed) */
106- kNoVolume /* default volume level */
107- );
108- osErr = GetMoviesError ();
109- if (osErr)
110- {
111- printf ("NewMovieTrack failed %d\n", osErr);
112- goto bail;
113- }
114-
115-
116- /* Step 3: Add a new media to that track (NewTrackMedia).
117- ======================================================= */
118-
119- media = NewTrackMedia
120- (
121- track, /* the track to add the media to */
122- VideoMediaType, /* media type, e.g. SoundMediaType */
123- 600, /* num media time units that elapse/sec*/
124- NULL, /* ptr to file that holds media sampls*/
125- 0 /* type of ptr to media samples */
126- );
127- osErr = GetMoviesError ();
128- if (osErr)
129- {
130- printf ("NewTrackMedia failed %d\n", osErr);
131- goto bail;
132- }
133-
134- /* Step 4: Add media samples to the media.
135- ======================================== */
136-
137- BeginMediaEdits (media); /* Inform the Movie Toolbox that we */
138- /* want to change the media samples */
139- /* referenced by a track's media. */
140- /* This opens the media container */
141- /* and makes it ready to receive */
142- /* and/or remove sample data. */
143-
144-
145-
146-
147- // Step 5: setup graphics port for qt movie and compression type ---
148-
149- /* Create a new offscreen graphics world that will hold the movie's
150- drawing surface. draw_image() copies the image of IceFlow to this
151- surface with varying amounts of transparency.
152- ================================================================= */
153-
154- MacSetRect (&rect, 0, 0, w, h);
155-
156- osErr = NewGWorld
157- (
158- &pMovieGWorld, /* receives the new GWorld. */
159- 24, /* pixel depth in bits/pixel */
160- &rect, /* desired size of the GWorld. */
161- NULL,
162- NULL,
163- (GWorldFlags) 0
164- );
165- if (osErr != noErr)
166- {
167- printf ("NewGWorld 1 failed %d\n", osErr);
168- goto bail;
169- }
170-
171-
172-/* Retrieve the pixel map associated with that graphics world and lock
173- the pixel map in memory. GetMaxCompressionSize() and CompressImage()
174- only operate on pixel maps, not graphics worlds.
175- ===================================================================== */
176-
177- pixMapHandle = GetGWorldPixMap (pMovieGWorld);
178- if (pixMapHandle == NULL)
179- {
180- printf ("GetGWorldPixMap failed\n");
181- goto bail;
182- }
183- LockPixels (pixMapHandle);
184-
185-
186-/* Get the maximum number of bytes required to hold an image having the
187- specified characteristics compressed using the specified compressor.
188- ==================================================================== */
189-
190-
191- osErr = GetMaxCompressionSize
192- (
193- pixMapHandle, /* the pixel map to compress from. */
194- &rect, /* the image rectangle. */
195- 0, /* let ICM choose image bit depth. */
196- codecHighQuality, /* compression quality specifier. */
197- kRawCodecType, /* desired compression type */ // < set to RAW in case we set to a new compression type...
198- (CompressorComponent) anyCodec, /* codec specifier. */
199- &lMaxCompressionSize /* receives max bytes needed for cmp. */
200- );
201- if (osErr != noErr)
202- {
203- printf ("GetMaxCompressionSize failed %d\n", osErr);
204- goto bail;
205- }
206-
207-
208-/* Allocate a buffer to hold the compressed image data by creating a new
209- handle.
210- ===================================================================== */
211- hCompressedData = NewHandle (lMaxCompressionSize);
212- if (hCompressedData == NULL)
213- {
214- printf ("NewHandle(%ld) failed\n", lMaxCompressionSize);
215- goto bail;
216- }
217-
218-/* Lock the handle and then dereference it to obtain a pointer to the data
219- buffer because CompressImage() wants us to pass it a pointer, not a
220- handle.
221- ======================================================================= */
222-
223- HLockHi (hCompressedData);
224- pCompressedData = *hCompressedData;
225-
226-/* Create an image description object in memory of minimum size to pass
227- to CompressImage(). CompressImage() will resize the memory as
228- necessary so create it small here.
229- ==================================================================== */
230-
231- hImageDescription = (ImageDescriptionHandle) NewHandle (4);
232- if (hImageDescription == NULL)
233- {
234- printf ("NewHandle(4) failed\n");
235- goto bail;
236- }
237-
238-
239-
240- bSetupForRecordingMovie = true;
241- return;
242-
243-
244-
245-
246- bail:
247- printf("got to bail somehows \n");
248- if (sResRefNum != 0) CloseMovieFile (sResRefNum);
249- if (movie != NULL) DisposeMovie (movie);
250-
251- //ExitMovies (); /* Finalize Quicktime */
252-
253- return;
254-}
255-
256-void ofxQtVideoSaver::addAudioTrack(string audioPath)
257-{
258-
259-
260- //OSErr err;
261-// Handle dataRef = NULL;
262-// FSSpec fileSpec;
263-// short audioMovieRefNum = 0;
264-// short audioMovieResId = 0;
265-// Movie audioMovie = NULL;
266-// Track audioCopyTrack = NULL;
267-// Media audioCopyMedia = NULL;
268-// Track destTrack = NULL;
269-// Media destMedia = NULL;
270-//
271-// destTrack = NewMovieTrack (movie, 0, 0, kFullVolume);
272-// destMedia = NewTrackMedia (destTrack, SoundMediaType,
273-// 30. * 100, /* Video Time Scale */
274-// nil, 0);
275-//
276-// err = BeginMediaEdits (destMedia);
277-//
278-// char * p = new char[audioPath.length()+1];
279-// strcpy(p, audioPath.c_str());
280-// NativePathNameToFSSpec(p, &fileSpec, 0L);
281-//
282-// err = OpenMovieFile(&fileSpec, &audioMovieRefNum, fsRdPerm);
283-// err = NewMovieFromFile(&audioMovie, audioMovieRefNum, &audioMovieResId, NULL, newMovieActive, NULL);
284-// err = CloseMovieFile(audioMovieRefNum);
285-//
286-// SetMovieTimeScale(audioMovie, 30.*100);
287-//
288-// audioCopyTrack = GetMovieTrack(audioMovie, 1);
289-// audioCopyMedia = GetTrackMedia(audioCopyTrack);
290-//
291-// long duration = GetMovieDuration(audioMovie);
292-//
293-// err = AddEmptyTrackToMovie (audioCopyTrack, movie, nil, nil, &destTrack);
294-// err = InsertTrackSegment(audioCopyTrack, destTrack, 0, duration, 0);
295-// err = EndMediaEdits(destMedia);
296-}
297-
298-
299-
300-//--------------------------------------------------------------
301-void ofxQtVideoSaver::listCodecs(){
302-
303- initializeQuicktime();
304-
305- OSStatus error = noErr;
306- CodecNameSpecListPtr list;
307- CodecNameSpec * codecNameSpecPtr;
308- char typeName[32];
309-
310- error = GetCodecNameList( &list, 0 );
311- if ( error ) return;
312-
313- int numCodecs = list->count;
314- codecNameSpecPtr = (CodecNameSpec *)((short *)list + 1);
315-
316- for (int i = 0; i < numCodecs; i++ ){
317- p2cstrcpy( typeName, codecNameSpecPtr->typeName );
318- printf("codec (%i) = %s \n", i, typeName);
319- codecNameSpecPtr++;
320- }
321- DisposeCodecNameList( list );
322-}
323-
324-//--------------------------------------------------------------
325-void ofxQtVideoSaver::setCodecType( int chosenCodec ){
326-
327- initializeQuicktime();
328-
329- OSStatus error = noErr;
330- CodecNameSpecListPtr list;
331- CodecNameSpec * codecNameSpecPtr;
332- char typeName[32];
333-
334- error = GetCodecNameList( &list, 0 );
335- if ( error ) return;
336-
337- int numCodecs = list->count;
338- codecNameSpecPtr = (CodecNameSpec *)((short *)list + 1);
339-
340- for (int i = 0; i < numCodecs; i++ ){
341- if (i == chosenCodec){
342- p2cstrcpy( typeName, codecNameSpecPtr->typeName );
343- printf("trying to set codec type to (%s) \n", typeName);
344- codecType = codecNameSpecPtr->cType;
345- }
346- codecNameSpecPtr++;
347- }
348-}
349-
350-
351-//-----------------------------------------------------------------------------
352-void ofxQtVideoSaver::finishMovie(){
353-
354- if (!bSetupForRecordingMovie) return;
355-
356- bSetupForRecordingMovie = false;
357-
358-
359- EndMediaEdits (media); /* Inform the Movie Toolbox that they */
360- /* can close the media container. */
361-
362-
363- /* Step 5: Insert a reference into the track that specifies which of the
364- media samples to play and when to start playing them.
365- ====================================================================== */
366-
367- InsertMediaIntoTrack
368- (
369- track, /* the track to update. */
370- 0, /* time in track where the specified */
371- /* media samples should start playg */
372- /* using movie time scale. */
373- 0, /* time in media samples of the first */
374- /* sample to play using media time */
375- /* scale. */
376- GetMediaDuration (media), /* duration of media samples to play */
377- /* using media time scale. */
378- 1L<<16 //fixed1 /* rate at which to play the samples. */
379- );
380-
381-
382-/* Step 6: Append the movie atom to the movie file (AddMovieResource).
383- ==================================================================== */
384-
385- sResId = movieInDataForkResID;
386- osErr = AddMovieResource
387- (
388- movie, /* movie to create moov atom from */
389- sResRefNum, /* file to receive the moov atom */
390- &sResId, /* id num of movie resource (res fork)*/
391- (unsigned char *) fileName.c_str() /* name of movie resource (res fork) */
392- );
393- if (osErr)
394- {
395- printf ("AddMovieResource failed %d\n", osErr);
396- goto bail;
397- }
398-
399- if (sResRefNum != 0)
400- {
401- CloseMovieFile (sResRefNum); /* close file CreateMovieFile opened */
402- sResRefNum = 0;
403- }
404-
405-
406- /* Step 7 (optional): Place the movie atom as the first atom in a new
407- movie file, and interleave the media data (FlattenMovieData).
408- =================================================================== */
409-
410- // no flattening necessary I think .....
411- // if (bFlatten) flatten_my_movie (movie, pszFlatFilename);
412-
413-
414- /* Step 8: Close the movie file that CreateMovieFile opened (if necessary)
415- and dispose of the movie memory structures (DisposeMovie).
416- ======================================================================== */
417-
418-
419-
420- SetGWorld (pSavedPort, hSavedDevice);
421- DisposeMovie (movie);
422- if (hImageDescription != NULL) DisposeHandle ((Handle) hImageDescription);
423- if (hCompressedData != NULL) DisposeHandle (hCompressedData);
424- if (pMovieGWorld != NULL) DisposeGWorld (pMovieGWorld);
425-
426- closeQuicktime();
427-
428- bail:
429-
430- if (sResRefNum != 0) CloseMovieFile (sResRefNum);
431- if (movie != NULL) DisposeMovie (movie);
432-
433-}
434-
435-void ofxQtVideoSaver::addFrame(unsigned char* data, float frameLengthInSecs){
436-
437- if (!bSetupForRecordingMovie) return;
438-
439-/* Save the current GWorld and set the offscreen GWorld as current.
440- ================================================================ */
441-
442- GetGWorld (&pSavedPort, &hSavedDevice);
443- SetGWorld (pMovieGWorld, NULL);
444-
445- Ptr gwAddress, gwAddressBase;
446- long gwWidth;
447- float timeForQt = 0;
448- gwAddressBase = GetPixBaseAddr( GetGWorldPixMap( pMovieGWorld ) ); /* Get head address of offscreen */
449- gwWidth = ( **GetGWorldPixMap( pMovieGWorld ) ).rowBytes & 0x3fff; /* Get with of offscreen */
450- ///gwAddress = gwAddressBase + ( x * 3 ) + ( y * gwWidth ); /* Get adress for current pixel */
451- int myWidth = w*3;
452- unsigned char * myData = data;
453-
454- #ifdef TARGET_OSX
455- //---------------------------------------------------------------
456- // mac's have 32 bit no matter what, so we do it like this:
457- for (int i = 0; i < h; i++){
458- gwAddress = gwAddressBase + i * gwWidth;
459- myData = data + i * myWidth;
460- for (int j = 0; j < w; j++){
461- memcpy(gwAddress+1, myData, 3);
462- /*gwAddress[1] = myData[2];
463- gwAddress[2] = myData[1];
464- gwAddress[3] = myData[0];*/
465- gwAddress+= 4;
466- myData+= 3;
467- }
468- }
469- #endif
470-
471- #ifdef TARGET_WIN32
472- for (int i = 0; i < h; i++){
473- gwAddress = gwAddressBase + i * gwWidth;
474- myData = data + i * myWidth;
475- memcpy(gwAddress, myData, myWidth);
476- }
477- #endif
478-
479-
480-
481-
482- /* Compress the pixel map that has just been drawn on. Also resize
483- and fill in the image description. Resulting image size can be
484- discovered by consulting the image description field dataSize.
485- ================================================================ */
486-
487- osErr = CompressImage
488- (
489- pixMapHandle, /* the pixel map of the offscreen img */
490- &rect, /* portion of the image to compress */
491- codecQualityLevel, /* quality as set via default or #defines */
492- codecType, /* same codec specifier as above */
493- hImageDescription, /* the created image description. */
494- pCompressedData /* ptr to bufr that receives cmp image*/
495- );
496- if (osErr != noErr)
497- {
498- printf ("CompressImage failed %d\n", osErr);
499- goto bail;
500- }
501-
502-
503-/* Add the compressed image to the movie.
504- ====================================== */
505-
506- // converting frame length to a time duration;
507- timeForQt = 1 / frameLengthInSecs;
508-
509- osErr = AddMediaSample
510- (
511- media, /* the media to add the image to. */
512- hCompressedData, /* the compressed image to add. */
513- 0, /* byte offs into data to begin readg */
514- (**hImageDescription).dataSize,/* num bytes to be copied into media. */
515- 600 / timeForQt, /* duration of the frame (media time) */
516- (SampleDescriptionHandle) hImageDescription, /* image desc cast to */
517- /* a sample description since both */
518- /* both structures start with same */
519- /* fields. */
520- 1, /* num samples in the data buffer. */
521- 0, /* default flags */
522- NULL /* ptr to receive media time in which */
523- /* the image was added. */
524- );
525- if (osErr != noErr)
526- {
527- printf ("AddMediaSample failed %d\n", osErr);
528- //goto bail;
529- }
530-
531-
532- return;
533-
534- bail:
535-
536- SetGWorld (pSavedPort, hSavedDevice);
537- if (hImageDescription != NULL) DisposeHandle ((Handle) hImageDescription);
538- if (hCompressedData != NULL) DisposeHandle (hCompressedData);
539- if (pMovieGWorld != NULL) DisposeGWorld (pMovieGWorld);
540-}
541-
542-
543-//--------------------------------------------------------
544-void ofxQtVideoSaver::setGworldPixel( GWorldPtr gwPtr, int r, int g, int b, short x, short y){
545- Ptr gwAddress, gwAddressBase;
546- long gwWidth;
547- char red, blue, green;
548- gwAddressBase = GetPixBaseAddr( GetGWorldPixMap( gwPtr ) ); /* Get head address of offscreen */
549- gwWidth = ( **GetGWorldPixMap( gwPtr ) ).rowBytes & 0x3fff; /* Get with of offscreen */
550- gwAddress = gwAddressBase + ( x * 3 ) + ( y * gwWidth ); /* Get adress for current pixel */
551- *gwAddress = (unsigned char)r; /* Put red and move address forward */
552- *(gwAddress+1) = (unsigned char)g; /* Put green and move address forward */
553- *(gwAddress+2) = (unsigned char)b; /* Put blue */
554-}
--- a/myprj/pictMove/ofxQtVideoSaver.h
+++ /dev/null
@@ -1,64 +0,0 @@
1-#ifndef _QT_VIDEO_GRABBER_
2-#define _QT_VIDEO_GRABBER_
3-
4-#include "ofConstants.h"
5-#include "ofQtUtils.h"
6-#include "ofUtils.h"
7-
8-#define OF_QT_SAVER_CODEC_QUALITY_LOSSLESS 0x00000400
9-#define OF_QT_SAVER_CODEC_QUALITY_MAX 0x000003FF
10-#define OF_QT_SAVER_CODEC_QUALITY_HIGH 0x00000300
11-#define OF_QT_SAVER_CODEC_QUALITY_NORMAL 0x00000200
12-#define OF_QT_SAVER_CODEC_QUALITY_LOW 0x00000100
13-#define OF_QT_SAVER_CODEC_QUALITY_MIN 0x00000000
14-
15-class ofxQtVideoSaver{
16-
17- public :
18- ofxQtVideoSaver ();
19- void setup (int width , int height , string fileName );
20- void finishMovie ();
21- void addFrame (unsigned char* data, float frameLengthInSecs = (1/30.0f));
22- void listCodecs ();
23- void setCodecType (int chosenCodec );
24- void setGworldPixel (GWorldPtr gwPtr, int r, int g, int b, short x, short y); // just for checking...
25-
26- void setCodecQualityLevel (int level); // see the #defines above...
27-
28- bool bAmSetupForRecording () { return bSetupForRecordingMovie; }
29- void addAudioTrack(string audioPath);
30- private:
31-
32- //-------------------------------- movie
33-
34- bool bSetupForRecordingMovie;
35-
36-
37- int w;
38- int h;
39- int codecQualityLevel;
40- OSErr osErr;
41- short sResId;
42- short sResRefNum;
43- FSSpec fsSpec;
44- Movie movie;
45- Track track;
46- Media media;
47- string fileName;
48- FSRef fsref;
49-
50- // ------------------------------- frame
51- Rect rect;
52- RGBColor rgbColor;
53- CodecType codecType;
54- GWorldPtr pMovieGWorld;
55- PixMapHandle pixMapHandle;
56- Ptr pCompressedData;
57- CGrafPtr pSavedPort;
58- GDHandle hSavedDevice;
59- Handle hCompressedData;
60- long lMaxCompressionSize;
61- ImageDescriptionHandle hImageDescription;
62-};
63-
64-#endif
--- a/myprj/pictMove/testApp.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
1-#include "testApp.h"
2-
3-static bool bRecording = false;
4-//--------------------------------------------------------------
5-void testApp::setup(){
6-
7- saver.listCodecs();
8- saver.setCodecType(4); //ZACH FIX see recording quicktime with sound in sync on of forum ←エンコード設定
9- saver.setCodecQualityLevel(OF_QT_SAVER_CODEC_QUALITY_MAX);
10- const string name = "/Users/samb/output.mov";
11- saver.setup(1024, 768, name);
12- bRecording = !bRecording;
13-
14-#if 0
15- // video
16- camWidth = 320; // try to grab at this size.
17- camHeight = 240;
18-
19- vidGrabber.setVerbose(true);
20- vidGrabber.initGrabber(camWidth,camHeight);
21-
22- videoInverted = new unsigned char[camWidth*camHeight*3];
23- //videoTexture.allocate(camWidth,camHeight, GL_RGB);
24-
25- // create a unique file name for this movie file
26- createFileName();
27-
28- // initialize a timestamp which we'll use to properly
29- // time the frame as they're added to the movie
30- mTimestamp = ofGetElapsedTimef();
31-
32- // init the movie saver
33- mVidSaver.setCodecQualityLevel(OF_QT_SAVER_CODEC_QUALITY_NORMAL);
34- mVidSaver.setup(camWidth, camHeight, mFileName);
35-#endif
36-
37-
38- ofBackground(34, 34, 34);
39-
40- // 2 output channels,
41- // 0 input channels
42- // 22050 samples per second
43- // 512 samples per buffer
44- // 4 num buffers (latency)
45-
46- int bufferSize = 512;
47- sampleRate = 44100;
48- phase = 0;
49- phaseAdder = 0.0f;
50- phaseAdderTarget = 0.0f;
51- volume = 0.1f;
52- bNoise = false;
53-
54- lAudio.assign(bufferSize, 0.0);
55- rAudio.assign(bufferSize, 0.0);
56-
57- //soundStream.listDevices();
58-
59- //if you want to set the device id to be different than the default
60- //soundStream.setDeviceID(1); //note some devices are input only and some are output only
61-
62- soundStream.setup(this, 2, 0, sampleRate, bufferSize, 4);
63-
64-
65- cnt = 0;
66-
67- //-- of dir
68- dir.listDir("/Users/samb/Pictures/pict_data_mknakami/");
69- dir.sort();
70-
71- if( dir.size() ) {
72- images.assign( dir.size(), ofImage() );
73- }
74-
75- for( int i = 0; i < (int) dir.size(); i++ ) {
76- printf("get path : %s\n", dir.getPath(i).c_str());
77- images[i].loadImage( dir.getPath( i ) );
78- }
79-
80-
81- ofSetFrameRate(60);
82-}
83-
84-
85-//--------------------------------------------------------------
86-void testApp::update(){
87-#if 0
88- vidGrabber.grabFrame();
89-
90- if (vidGrabber.isFrameNew()){
91- // figure out how much time elapsed since the last frame
92- float time = ofGetElapsedTimef() - mTimestamp;
93-
94- // add this frame to the movie
95- mVidSaver.addFrame(vidGrabber.getPixels(), time);
96-
97- // update the timestamp to the current time
98- mTimestamp = ofGetElapsedTimef();
99- }
100-#endif
101-}
102-
103-//--------------------------------------------------------------
104-void testApp::draw() {
105-
106- grabbedImage.grabScreen(0, 0, 1600,900);// copy!
107- if (bRecording == true){
108- saver.addFrame(grabbedImage.getPixels(), 4.0f / 30.0f);
109- // you can also pass in the frameRate:
110- // saver.addFrame(vidGrabber.getPixels(), 1.0f / 30.0f); // 30 fps for this frame
111- // saver.addFrame(vidGrabber.getPixels(), 1.0f / 5.0f); // 5 fps for this frame, etc....
112-
113- }
114-
115- //ofSetColor(255);
116- cnt++;
117-
118- ofNoFill();
119-
120- ofPushMatrix();
121- ofTranslate(0, 0, 0);
122-
123-#if 0
124- // video
125- vidGrabber.draw(0,0);
126-#endif
127-
128- int h = ofGetViewportHeight();
129- int w = ofGetViewportWidth();
130-
131-
132- glEnable(GL_DEPTH);
133-
134- float accel = 8.0;
135- accel = (accel * 0.6) + (1.0 * 0.2);
136- float speedPixelPerFrame = 5 * accel;
137- int x_offset = cnt * speedPixelPerFrame * -1;
138- int pictSizeX = 50;
139- int pictSizeY = 50;
140- int pictPosZ = -500;
141- double pictSpan = 0.2;
142-
143- for( int i = 0; i < (int) dir.size(); i++ ) {
144- x_offset += pictSizeX * (1.0 + pictSpan);
145- if( -w < x_offset && x_offset < w*2) {
146- images[i].draw( x_offset, h/2, pictPosZ, pictSizeX, pictSizeY );
147- }
148- }
149-
150-#if 0
151- ofSetColor(225);
152- ofDrawBitmapString("AUDIO OUTPUT EXAMPLE", 32, 32);
153- ofDrawBitmapString("press 's' to unpause the audio\npress 'e' to pause the audio", 31, 92);
154-
155- ofNoFill();
156-
157-
158-
159- // draw the left channel:
160- ofPushStyle();
161- ofPushMatrix();
162- ofTranslate(32, 150, 0);
163-
164- ofSetColor(225);
165- ofDrawBitmapString("Left Channel", 4, 18);
166-
167- ofSetLineWidth(1);
168- ofRect(0, 0, 900, 200);
169-
170- ofSetColor(245, 58, 135);
171- ofSetLineWidth(3);
172-
173- ofBeginShape();
174- for (int i = 0; i < lAudio.size(); i++){
175- float x = ofMap(i, 0, lAudio.size(), 0, 900, true);
176- ofVertex(x, 100 -lAudio[i]*180.0f);
177- }
178- ofEndShape(false);
179-
180- ofPopMatrix();
181- ofPopStyle();
182-
183- // draw the right channel:
184- ofPushStyle();
185- ofPushMatrix();
186- ofTranslate(32, 350, 0);
187-
188- ofSetColor(225);
189- ofDrawBitmapString("Right Channel", 4, 18);
190-
191- ofSetLineWidth(1);
192- ofRect(0, 0, 900, 200);
193-
194- ofSetColor(245, 58, 135);
195- ofSetLineWidth(3);
196-
197- ofBeginShape();
198- for (int i = 0; i < rAudio.size(); i++){
199- float x = ofMap(i, 0, rAudio.size(), 0, 900, true);
200- ofVertex(x, 100 -rAudio[i]*180.0f);
201- }
202- ofEndShape(false);
203-
204- ofPopMatrix();
205- ofPopStyle();
206-
207-
208- ofSetColor(225);
209- string reportString = "volume: ("+ofToString(volume, 2)+") modify with -/+ keys\npan: ("+ofToString(pan, 2)+") modify with mouse x\nsynthesis: ";
210- if( !bNoise ){
211- reportString += "sine wave (" + ofToString(targetFrequency, 2) + "hz) modify with mouse y";
212- }else{
213- reportString += "noise";
214- }
215- ofDrawBitmapString(reportString, 32, 579);
216-
217-#endif // 0
218-
219-}
220-
221-#if 0
222-void testApp::createFileName(void)
223-{
224- // create a uniqe file name
225- ostringstream oss;
226- oss << ofGetYear() << "-";
227- oss << setw(2) << setfill('0') << ofGetMonth() << "-";
228- oss << setw(2) << setfill('0') << ofGetDay() << "-";
229- oss << setw(2) << setfill('0') << ofGetHours() << "-";
230- oss << setw(2) << setfill('0') << ofGetMinutes() << "-";
231- oss << setw(2) << setfill('0') << ofGetSeconds() << ".mov";
232- mFileName = oss.str();
233-}
234-#endif
235-
236-//--------------------------------------------------------------
237-void testApp::keyPressed (int key){
238- if (key == '-' || key == '_' ){
239- volume -= 0.05;
240- volume = MAX(volume, 0);
241- } else if (key == '+' || key == '=' ){
242- volume += 0.05;
243- volume = MIN(volume, 1);
244- }
245-
246- if( key == 's' ){
247- soundStream.start();
248- }
249-
250- if( key == 'e' ){
251- soundStream.stop();
252- }
253-
254-}
255-
256-//--------------------------------------------------------------
257-void testApp::keyReleased (int key){
258- saver.finishMovie();
259- bRecording = false;
260-}
261-
262-//--------------------------------------------------------------
263-void testApp::mouseMoved(int x, int y ){
264- int width = ofGetWidth();
265- pan = (float)x / (float)width;
266- float height = (float)ofGetHeight();
267- float heightPct = ((height-y) / height);
268- targetFrequency = 2000.0f * heightPct;
269- phaseAdderTarget = (targetFrequency / (float) sampleRate) * TWO_PI;
270-}
271-
272-//--------------------------------------------------------------
273-void testApp::mouseDragged(int x, int y, int button){
274- int width = ofGetWidth();
275- pan = (float)x / (float)width;
276-}
277-
278-//--------------------------------------------------------------
279-void testApp::mousePressed(int x, int y, int button){
280- bNoise = true;
281-}
282-
283-
284-//--------------------------------------------------------------
285-void testApp::mouseReleased(int x, int y, int button){
286- bNoise = false;
287-}
288-
289-//--------------------------------------------------------------
290-void testApp::windowResized(int w, int h){
291-
292-}
293-
294-//--------------------------------------------------------------
295-void testApp::audioOut(float * output, int bufferSize, int nChannels){
296-
297-#if 0
298- //pan = 0.5f;
299- float leftScale = 1 - pan;
300- float rightScale = pan;
301-
302- // sin (n) seems to have trouble when n is very large, so we
303- // keep phase in the range of 0-TWO_PI like this:
304- while (phase > TWO_PI){
305- phase -= TWO_PI;
306- }
307-
308- if ( bNoise == true){
309- // ---------------------- noise --------------
310- for (int i = 0; i < bufferSize; i++){
311- lAudio[i] = output[i*nChannels ] = ofRandom(0, 1) * volume * leftScale;
312- rAudio[i] = output[i*nChannels + 1] = ofRandom(0, 1) * volume * rightScale;
313- }
314- } else {
315- phaseAdder = 0.95f * phaseAdder + 0.05f * phaseAdderTarget;
316- for (int i = 0; i < bufferSize; i++){
317- phase += phaseAdder;
318- float sample = sin(phase);
319- lAudio[i] = output[i*nChannels ] = sample * volume * leftScale;
320- rAudio[i] = output[i*nChannels + 1] = sample * volume * rightScale;
321- }
322- }
323-#endif
324-}
325-
326-//--------------------------------------------------------------
327-void testApp::gotMessage(ofMessage msg){
328-
329-}
330-
331-//--------------------------------------------------------------
332-void testApp::dragEvent(ofDragInfo dragInfo){
333-
334-}
--- a/myprj/pictMove/testApp.h
+++ /dev/null
@@ -1,69 +0,0 @@
1-#ifndef _TEST_APP
2-#define _TEST_APP
3-
4-
5-#include "ofMain.h"
6-#include "ofxQTVideoSaver.h"
7-
8-class testApp : public ofBaseApp{
9-
10-public:
11-
12- void setup();
13- void update();
14- void draw();
15-
16- void keyPressed(int key);
17- void keyReleased(int key);
18- void mouseMoved(int x, int y );
19- void mouseDragged(int x, int y, int button);
20- void mousePressed(int x, int y, int button);
21- void mouseReleased(int x, int y, int button);
22- void windowResized(int w, int h);
23- void dragEvent(ofDragInfo dragInfo);
24- void gotMessage(ofMessage msg);
25-
26- void audioOut(float * input, int bufferSize, int nChannels);
27- void createFileName(void);
28-
29- ofSoundStream soundStream;
30-
31- float pan;
32- int sampleRate;
33- bool bNoise;
34- float volume;
35-
36- vector <float> lAudio;
37- vector <float> rAudio;
38-
39- //------------------- for the simple sine wave synthesis
40- float targetFrequency;
41- float phase;
42- float phaseAdder;
43- float phaseAdderTarget;
44-
45- //------
46- ofDirectory dir;
47- vector<ofImage> images;
48- int cnt;
49-
50- ofVideoPlayer mov;
51- ofxQtVideoSaver saver;
52- ofImage grabbedImage;
53-
54-#if 0
55- //--- ofx qt video
56- ofVideoGrabber vidGrabber;
57- unsigned char * videoInverted;
58- ofTexture videoTexture;
59- int camWidth;
60- int camHeight;
61-
62- ofImage mColorImage;
63- ofxQtVideoSaver mVidSaver;
64- string mFileName;
65- float mTimestamp;
66-#endif
67-};
68-
69-#endif
--- a/myprj/rtaudioTest/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
1-#-------------------------------------------------------------------------------
2-# RtAudioテストプロジェクト
3-# of_preRelease_v007_osx向けMakefileを使用
4-#-------------------------------------------------------------------------------
5-CC = gcc -arch i386
6-CPP = g++ -arch i386
7-CFLAGS = -g -Wall
8-LDFLAGS = -L/usr/local/lib
9-LIBS = -lm
10-DEST = /usr/local/bin
11-OBJS = main.o
12-PROGRAM = run
13-
14-# openframeworkの共通定義をインクルード
15-include ../Makefile-of.mk
16-
17-# サフィックスルール適用対象の拡張子の定義
18-.SUFFIXES: .c .cpp .o
19-
20-# サフィックスルール
21-.c.o:
22- $(CC) $(CFLAGS) $(OF_CORE_HEADERS) -c $<
23-
24-.cpp.o:
25- $(CPP) $(CFLAGS) $(OF_CORE_HEADERS) -c $<
26-
27-all: $(PROGRAM)
28-
29-$(PROGRAM): $(OBJS)
30- $(CPP) $(LDFLAGS) $(LIBS) $(OF_LINK) $(OBJS) -o $(PROGRAM)
31- chmod 755 $(PROGRAM)
32-
33-clean:; rm -f *.o *~ $(PROGRAM)
34-
35-install: $(PROGRAM)
36- install -s $(PROGRAM) $(DEST)
--- a/myprj/rtaudioTest/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
1-#include <stdio.h>
2-#include <math.h>
3-#include "RtAudio.h"
4-
5-#include <iostream>
6-#include <cstdlib>
7-
8-// Two-channel sawtooth wave generator.
9-int saw( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
10- double streamTime, RtAudioStreamStatus status, void *userData )
11-{
12- unsigned int i, j;
13- double *buffer = (double *) outputBuffer;
14- double *lastValues = (double *) userData;
15-
16- if ( status )
17- std::cout << "Stream underflow detected!" << std::endl;
18-
19- // Write interleaved audio data.
20- for ( i=0; i<nBufferFrames; i++ ) {
21- for ( j=0; j<2; j++ ) {
22- *buffer++ = lastValues[j];
23-
24- lastValues[j] += 0.005 * (j+1+(j*0.1));
25- if ( lastValues[j] >= 1.0 ) lastValues[j] -= 2.0;
26- }
27- }
28-
29- return 0;
30-}
31-
32-int main(int argc, char *argv[])
33-{
34- printf("OF Lib RtAudio test\n");
35-
36- RtAudio dac;
37- if ( dac.getDeviceCount() < 1 ) {
38- std::cout << "\nNo audio devices found!\n";
39- exit( 0 );
40- }
41-
42- RtAudio::StreamParameters parameters;
43- parameters.deviceId = dac.getDefaultOutputDevice();
44- parameters.nChannels = 2;
45- parameters.firstChannel = 0;
46- unsigned int sampleRate = 44100;
47- unsigned int bufferFrames = 256; // 256 sample frames
48- double data[2];
49-
50- try {
51- dac.openStream( &parameters, NULL, RTAUDIO_FLOAT64,
52- sampleRate, &bufferFrames, &saw, (void *)&data );
53- dac.startStream();
54- }
55- catch ( RtError& e ) {
56- e.printMessage();
57- exit( 0 );
58- }
59-
60- char input;
61- std::cout << "\nPlaying ... press <enter> to quit.\n";
62- std::cin.get( input );
63- try {
64- // Stop the stream
65- dac.stopStream();
66- }
67- catch (RtError& e) {
68- e.printMessage();
69- }
70-
71- if ( dac.isStreamOpen() ) dac.closeStream();
72- return 0;
73-}
74-
75-
76-
--- a/myprj/test/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
1-#-------------------------------------------------------------------------------
2-# of_preRelease_v007_osx向けMakefile
3-#
4-# + of_preRelease_v007_osx.zipを展開する
5-# + MakefileのOF_PATHをof_preRelease_v007_osx.zip展開した場所
6-# + libs/fmodex/lib/osx/libfmodex.dylibは実行前に/usr/libとかへコピーしとく
7-#-------------------------------------------------------------------------------
8-CC = gcc -arch i386
9-CPP = g++ -arch i386
10-CFLAGS = -g -Wall
11-LDFLAGS = -L/usr/local/lib
12-LIBS = -lm
13-DEST = /usr/local/bin
14-OBJS = main.o testApp.o
15-PROGRAM = run
16-
17-# openframeworkの共通定義をインクルード
18-include ../Makefile-of.mk
19-
20-# サフィックスルール適用対象の拡張子の定義
21-.SUFFIXES: .c .cpp .o
22-
23-# サフィックスルール
24-.c.o:
25- $(CC) $(CFLAGS) $(OF_CORE_HEADERS) -c $<
26-
27-.cpp.o:
28- $(CPP) $(CFLAGS) $(OF_CORE_HEADERS) -c $<
29-
30-all: $(PROGRAM)
31-
32-$(PROGRAM): $(OBJS)
33- $(CPP) $(LDFLAGS) $(LIBS) $(OF_LINK) $(OBJS) -o $(PROGRAM)
34- chmod 755 $(PROGRAM)
35-
36-clean:; rm -f *.o *~ $(PROGRAM)
37-
38-install: $(PROGRAM)
39- install -s $(PROGRAM) $(DEST)
--- a/myprj/test/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
1-#include <stdio.h>
2-#include <math.h>
3-#include <iostream>
4-
5-#include "ofMain.h"
6-#include "testApp.h"
7-#include "ofAppGlutWindow.h"
8-
9-int main(int argc, char *argv[])
10-{
11- printf("OF Lib project test\n");
12-
13- ofAppGlutWindow window;
14- ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
15-
16- // this kicks off the running of my app
17- // can be OF_WINDOW or OF_FULLSCREEN
18- // pass in width and height too:
19- ofRunApp( new testApp());
20-}
21-
22-
23-
--- a/myprj/test/testApp.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
1-#include "testApp.h"
2-
3-//--------------------------------------------------------------
4-void testApp::setup(){
5-
6- ofBackground(34, 34, 34);
7-
8- // 2 output channels,
9- // 0 input channels
10- // 22050 samples per second
11- // 512 samples per buffer
12- // 4 num buffers (latency)
13-
14- int bufferSize = 512;
15- sampleRate = 44100;
16- phase = 0;
17- phaseAdder = 0.0f;
18- phaseAdderTarget = 0.0f;
19- volume = 0.1f;
20- bNoise = false;
21-
22- lAudio.assign(bufferSize, 0.0);
23- rAudio.assign(bufferSize, 0.0);
24-
25- //soundStream.listDevices();
26-
27- //if you want to set the device id to be different than the default
28- //soundStream.setDeviceID(1); //note some devices are input only and some are output only
29-
30- soundStream.setup(this, 2, 0, sampleRate, bufferSize, 4);
31-
32- ofSetFrameRate(60);
33-}
34-
35-
36-//--------------------------------------------------------------
37-void testApp::update(){
38-
39-}
40-
41-//--------------------------------------------------------------
42-void testApp::draw(){
43-
44-
45- ofSetColor(100);
46-
47- ofNoFill();
48-
49- ofPushMatrix();
50- ofTranslate(0, 0, 0);
51-
52- int h = ofGetViewportHeight();
53- int w = ofGetViewportWidth();
54-
55- ofLine(0, 0, w>>1, h>>1);
56-
57-
58-
59-
60-#if 0
61- ofSetColor(225);
62- ofDrawBitmapString("AUDIO OUTPUT EXAMPLE", 32, 32);
63- ofDrawBitmapString("press 's' to unpause the audio\npress 'e' to pause the audio", 31, 92);
64-
65- ofNoFill();
66-
67-
68-
69- // draw the left channel:
70- ofPushStyle();
71- ofPushMatrix();
72- ofTranslate(32, 150, 0);
73-
74- ofSetColor(225);
75- ofDrawBitmapString("Left Channel", 4, 18);
76-
77- ofSetLineWidth(1);
78- ofRect(0, 0, 900, 200);
79-
80- ofSetColor(245, 58, 135);
81- ofSetLineWidth(3);
82-
83- ofBeginShape();
84- for (int i = 0; i < lAudio.size(); i++){
85- float x = ofMap(i, 0, lAudio.size(), 0, 900, true);
86- ofVertex(x, 100 -lAudio[i]*180.0f);
87- }
88- ofEndShape(false);
89-
90- ofPopMatrix();
91- ofPopStyle();
92-
93- // draw the right channel:
94- ofPushStyle();
95- ofPushMatrix();
96- ofTranslate(32, 350, 0);
97-
98- ofSetColor(225);
99- ofDrawBitmapString("Right Channel", 4, 18);
100-
101- ofSetLineWidth(1);
102- ofRect(0, 0, 900, 200);
103-
104- ofSetColor(245, 58, 135);
105- ofSetLineWidth(3);
106-
107- ofBeginShape();
108- for (int i = 0; i < rAudio.size(); i++){
109- float x = ofMap(i, 0, rAudio.size(), 0, 900, true);
110- ofVertex(x, 100 -rAudio[i]*180.0f);
111- }
112- ofEndShape(false);
113-
114- ofPopMatrix();
115- ofPopStyle();
116-
117-
118- ofSetColor(225);
119- string reportString = "volume: ("+ofToString(volume, 2)+") modify with -/+ keys\npan: ("+ofToString(pan, 2)+") modify with mouse x\nsynthesis: ";
120- if( !bNoise ){
121- reportString += "sine wave (" + ofToString(targetFrequency, 2) + "hz) modify with mouse y";
122- }else{
123- reportString += "noise";
124- }
125- ofDrawBitmapString(reportString, 32, 579);
126-
127-#endif // 0
128-
129-}
130-
131-
132-//--------------------------------------------------------------
133-void testApp::keyPressed (int key){
134- if (key == '-' || key == '_' ){
135- volume -= 0.05;
136- volume = MAX(volume, 0);
137- } else if (key == '+' || key == '=' ){
138- volume += 0.05;
139- volume = MIN(volume, 1);
140- }
141-
142- if( key == 's' ){
143- soundStream.start();
144- }
145-
146- if( key == 'e' ){
147- soundStream.stop();
148- }
149-
150-}
151-
152-//--------------------------------------------------------------
153-void testApp::keyReleased (int key){
154-
155-}
156-
157-//--------------------------------------------------------------
158-void testApp::mouseMoved(int x, int y ){
159- int width = ofGetWidth();
160- pan = (float)x / (float)width;
161- float height = (float)ofGetHeight();
162- float heightPct = ((height-y) / height);
163- targetFrequency = 2000.0f * heightPct;
164- phaseAdderTarget = (targetFrequency / (float) sampleRate) * TWO_PI;
165-}
166-
167-//--------------------------------------------------------------
168-void testApp::mouseDragged(int x, int y, int button){
169- int width = ofGetWidth();
170- pan = (float)x / (float)width;
171-}
172-
173-//--------------------------------------------------------------
174-void testApp::mousePressed(int x, int y, int button){
175- bNoise = true;
176-}
177-
178-
179-//--------------------------------------------------------------
180-void testApp::mouseReleased(int x, int y, int button){
181- bNoise = false;
182-}
183-
184-//--------------------------------------------------------------
185-void testApp::windowResized(int w, int h){
186-
187-}
188-
189-//--------------------------------------------------------------
190-void testApp::audioOut(float * output, int bufferSize, int nChannels){
191- //pan = 0.5f;
192- float leftScale = 1 - pan;
193- float rightScale = pan;
194-
195- // sin (n) seems to have trouble when n is very large, so we
196- // keep phase in the range of 0-TWO_PI like this:
197- while (phase > TWO_PI){
198- phase -= TWO_PI;
199- }
200-
201- if ( bNoise == true){
202- // ---------------------- noise --------------
203- for (int i = 0; i < bufferSize; i++){
204- lAudio[i] = output[i*nChannels ] = ofRandom(0, 1) * volume * leftScale;
205- rAudio[i] = output[i*nChannels + 1] = ofRandom(0, 1) * volume * rightScale;
206- }
207- } else {
208- phaseAdder = 0.95f * phaseAdder + 0.05f * phaseAdderTarget;
209- for (int i = 0; i < bufferSize; i++){
210- phase += phaseAdder;
211- float sample = sin(phase);
212- lAudio[i] = output[i*nChannels ] = sample * volume * leftScale;
213- rAudio[i] = output[i*nChannels + 1] = sample * volume * rightScale;
214- }
215- }
216-
217-}
218-
219-//--------------------------------------------------------------
220-void testApp::gotMessage(ofMessage msg){
221-
222-}
223-
224-//--------------------------------------------------------------
225-void testApp::dragEvent(ofDragInfo dragInfo){
226-
227-}
--- a/myprj/test/testApp.h
+++ /dev/null
@@ -1,45 +0,0 @@
1-#ifndef _TEST_APP
2-#define _TEST_APP
3-
4-
5-#include "ofMain.h"
6-
7-class testApp : public ofBaseApp{
8-
9- public:
10-
11- void setup();
12- void update();
13- void draw();
14-
15- void keyPressed(int key);
16- void keyReleased(int key);
17- void mouseMoved(int x, int y );
18- void mouseDragged(int x, int y, int button);
19- void mousePressed(int x, int y, int button);
20- void mouseReleased(int x, int y, int button);
21- void windowResized(int w, int h);
22- void dragEvent(ofDragInfo dragInfo);
23- void gotMessage(ofMessage msg);
24-
25- void audioOut(float * input, int bufferSize, int nChannels);
26-
27-
28- ofSoundStream soundStream;
29-
30- float pan;
31- int sampleRate;
32- bool bNoise;
33- float volume;
34-
35- vector <float> lAudio;
36- vector <float> rAudio;
37-
38- //------------------- for the simple sine wave synthesis
39- float targetFrequency;
40- float phase;
41- float phaseAdder;
42- float phaseAdderTarget;
43-};
44-
45-#endif