scopeapp-cvs Mailing List for MacCRO X (Page 2)
Status: Alpha
Brought to you by:
narge
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(8) |
Jul
(52) |
Aug
(3) |
Sep
|
Oct
(7) |
Nov
(1) |
Dec
(31) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(10) |
Feb
(75) |
Mar
|
Apr
(17) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(11) |
Dec
|
From: <sco...@li...> - 2003-04-23 06:24:24
|
Update of /cvsroot/scopeapp/scopeapp/src/portaudio/pablio In directory sc8-pr-cvs1:/tmp/cvs-serv13792/pablio Added Files: ringbuffer.c ringbuffer.h Log Message: Update portaudio to v18-patch (checked out 23/04/03) --- NEW FILE: ringbuffer.c --- /* * $Id: ringbuffer.c,v 1.1 2003/04/23 06:24:19 narge Exp $ * ringbuffer.c * Ring Buffer utility.. * * Author: Phil Burk, http://www.softsynth.com * * This program uses the PortAudio Portable Audio Library. * For more information see: http://www.audiomulch.com/portaudio/ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk * * 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. * * Any person wishing to distribute modifications to the Software is * requested to send the modifications to the original developer so that * they can be incorporated into the canonical version. * * 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. * */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include "ringbuffer.h" #include <string.h> /*************************************************************************** * Initialize FIFO. * numBytes must be power of 2, returns -1 if not. */ long RingBuffer_Init( RingBuffer *rbuf, long numBytes, void *dataPtr ) { if( ((numBytes-1) & numBytes) != 0) return -1; /* Not Power of two. */ rbuf->bufferSize = numBytes; rbuf->buffer = (char *)dataPtr; RingBuffer_Flush( rbuf ); rbuf->bigMask = (numBytes*2)-1; rbuf->smallMask = (numBytes)-1; return 0; } /*************************************************************************** ** Return number of bytes available for reading. */ long RingBuffer_GetReadAvailable( RingBuffer *rbuf ) { return ( (rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask ); } /*************************************************************************** ** Return number of bytes available for writing. */ long RingBuffer_GetWriteAvailable( RingBuffer *rbuf ) { return ( rbuf->bufferSize - RingBuffer_GetReadAvailable(rbuf)); } /*************************************************************************** ** Clear buffer. Should only be called when buffer is NOT being read. */ void RingBuffer_Flush( RingBuffer *rbuf ) { rbuf->writeIndex = rbuf->readIndex = 0; } /*************************************************************************** ** Get address of region(s) to which we can write data. ** If the region is contiguous, size2 will be zero. ** If non-contiguous, size2 will be the size of second region. ** Returns room available to be written or numBytes, whichever is smaller. */ long RingBuffer_GetWriteRegions( RingBuffer *rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2 ) { long index; long available = RingBuffer_GetWriteAvailable( rbuf ); if( numBytes > available ) numBytes = available; /* Check to see if write is not contiguous. */ index = rbuf->writeIndex & rbuf->smallMask; if( (index + numBytes) > rbuf->bufferSize ) { /* Write data in two blocks that wrap the buffer. */ long firstHalf = rbuf->bufferSize - index; *dataPtr1 = &rbuf->buffer[index]; *sizePtr1 = firstHalf; *dataPtr2 = &rbuf->buffer[0]; *sizePtr2 = numBytes - firstHalf; } else { *dataPtr1 = &rbuf->buffer[index]; *sizePtr1 = numBytes; *dataPtr2 = NULL; *sizePtr2 = 0; } return numBytes; } /*************************************************************************** */ long RingBuffer_AdvanceWriteIndex( RingBuffer *rbuf, long numBytes ) { return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask; } /*************************************************************************** ** Get address of region(s) from which we can read data. ** If the region is contiguous, size2 will be zero. ** If non-contiguous, size2 will be the size of second region. ** Returns room available to be written or numBytes, whichever is smaller. */ long RingBuffer_GetReadRegions( RingBuffer *rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2 ) { long index; long available = RingBuffer_GetReadAvailable( rbuf ); if( numBytes > available ) numBytes = available; /* Check to see if read is not contiguous. */ index = rbuf->readIndex & rbuf->smallMask; if( (index + numBytes) > rbuf->bufferSize ) { /* Write data in two blocks that wrap the buffer. */ long firstHalf = rbuf->bufferSize - index; *dataPtr1 = &rbuf->buffer[index]; *sizePtr1 = firstHalf; *dataPtr2 = &rbuf->buffer[0]; *sizePtr2 = numBytes - firstHalf; } else { *dataPtr1 = &rbuf->buffer[index]; *sizePtr1 = numBytes; *dataPtr2 = NULL; *sizePtr2 = 0; } return numBytes; } /*************************************************************************** */ long RingBuffer_AdvanceReadIndex( RingBuffer *rbuf, long numBytes ) { return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask; } /*************************************************************************** ** Return bytes written. */ long RingBuffer_Write( RingBuffer *rbuf, void *data, long numBytes ) { long size1, size2, numWritten; void *data1, *data2; numWritten = RingBuffer_GetWriteRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 ); if( size2 > 0 ) { memcpy( data1, data, size1 ); data = ((char *)data) + size1; memcpy( data2, data, size2 ); } else { memcpy( data1, data, size1 ); } RingBuffer_AdvanceWriteIndex( rbuf, numWritten ); return numWritten; } /*************************************************************************** ** Return bytes read. */ long RingBuffer_Read( RingBuffer *rbuf, void *data, long numBytes ) { long size1, size2, numRead; void *data1, *data2; numRead = RingBuffer_GetReadRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 ); if( size2 > 0 ) { memcpy( data, data1, size1 ); data = ((char *)data) + size1; memcpy( data, data2, size2 ); } else { memcpy( data, data1, size1 ); } RingBuffer_AdvanceReadIndex( rbuf, numRead ); return numRead; } --- NEW FILE: ringbuffer.h --- #ifndef _RINGBUFFER_H #define _RINGBUFFER_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* * $Id: ringbuffer.h,v 1.1 2003/04/23 06:24:20 narge Exp $ * ringbuffer.h * Ring Buffer utility.. * * Author: Phil Burk, http://www.softsynth.com * * This program is distributed with the PortAudio Portable Audio Library. * For more information see: http://www.audiomulch.com/portaudio/ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk * * 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. * * Any person wishing to distribute modifications to the Software is * requested to send the modifications to the original developer so that * they can be incorporated into the canonical version. * * 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. * */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include "ringbuffer.h" #include <string.h> typedef struct { long bufferSize; /* Number of bytes in FIFO. Power of 2. Set by RingBuffer_Init. */ /* These are declared volatile because they are written by a different thread than the reader. */ volatile long writeIndex; /* Index of next writable byte. Set by RingBuffer_AdvanceWriteIndex. */ volatile long readIndex; /* Index of next readable byte. Set by RingBuffer_AdvanceReadIndex. */ long bigMask; /* Used for wrapping indices with extra bit to distinguish full/empty. */ long smallMask; /* Used for fitting indices to buffer. */ char *buffer; } RingBuffer; /* * Initialize Ring Buffer. * numBytes must be power of 2, returns -1 if not. */ long RingBuffer_Init( RingBuffer *rbuf, long numBytes, void *dataPtr ); /* Clear buffer. Should only be called when buffer is NOT being read. */ void RingBuffer_Flush( RingBuffer *rbuf ); /* Return number of bytes available for writing. */ long RingBuffer_GetWriteAvailable( RingBuffer *rbuf ); /* Return number of bytes available for read. */ long RingBuffer_GetReadAvailable( RingBuffer *rbuf ); /* Return bytes written. */ long RingBuffer_Write( RingBuffer *rbuf, void *data, long numBytes ); /* Return bytes read. */ long RingBuffer_Read( RingBuffer *rbuf, void *data, long numBytes ); /* Get address of region(s) to which we can write data. ** If the region is contiguous, size2 will be zero. ** If non-contiguous, size2 will be the size of second region. ** Returns room available to be written or numBytes, whichever is smaller. */ long RingBuffer_GetWriteRegions( RingBuffer *rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2 ); long RingBuffer_AdvanceWriteIndex( RingBuffer *rbuf, long numBytes ); /* Get address of region(s) from which we can read data. ** If the region is contiguous, size2 will be zero. ** If non-contiguous, size2 will be the size of second region. ** Returns room available to be written or numBytes, whichever is smaller. */ long RingBuffer_GetReadRegions( RingBuffer *rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2 ); long RingBuffer_AdvanceReadIndex( RingBuffer *rbuf, long numBytes ); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _RINGBUFFER_H */ |
From: <sco...@li...> - 2003-04-23 06:24:22
|
Update of /cvsroot/scopeapp/scopeapp/src/portaudio/pa_mac_core In directory sc8-pr-cvs1:/tmp/cvs-serv13792/pa_mac_core Modified Files: pa_mac_core.c Log Message: Update portaudio to v18-patch (checked out 23/04/03) Index: pa_mac_core.c =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_mac_core/pa_mac_core.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pa_mac_core.c 5 Dec 2002 14:46:43 -0000 1.1 --- pa_mac_core.c 23 Apr 2003 06:24:18 -0000 1.2 *************** *** 1,1261 **** ! /* ! * $Id$ ! * pa_mac_core.c ! * Implementation of PortAudio for Mac OS X Core Audio ! * ! * PortAudio Portable Real-Time Audio Library ! * Latest Version at: http://www.portaudio.com ! * ! * Authors: Ross Bencina and Phil Burk ! * Copyright (c) 1999-2000 Ross Bencina and Phil Burk [...3435 lines suppressed...] ! int Pa_CountDevices() ! { ! if( sNumPaDevices <= 0 ) Pa_Initialize(); ! return sNumPaDevices; ! } ! ! /************************************************************************* ! ** PaDeviceInfo structures have already been created ! ** so just return the pointer. ! ** ! */ ! const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID id ) ! { ! if( id < 0 || id >= sNumPaDevices ) ! return NULL; ! ! return &sDeviceInfos[id].paInfo; ! } ! ! |
From: <sco...@li...> - 2003-04-23 06:21:41
|
Update of /cvsroot/scopeapp/scopeapp/src/portaudio/pablio In directory sc8-pr-cvs1:/tmp/cvs-serv12991/pablio Log Message: Directory /cvsroot/scopeapp/scopeapp/src/portaudio/pablio added to the repository |
From: <sco...@li...> - 2003-02-20 13:22:09
|
Update of /cvsroot/scopeapp/scopeapp/MacCRO X.pbproj In directory sc8-pr-cvs1:/tmp/cvs-serv24907/MacCRO X.pbproj Modified Files: project.pbxproj Log Message: Workaround for an incompatibility with the latest version of Package Builder. Note that deployment builds will now need to be done on an HFS+ filesystem. |
From: <sco...@li...> - 2003-02-20 13:07:05
|
Update of /cvsroot/scopeapp/scopeapp/MacCRO X.pbproj In directory sc8-pr-cvs1:/tmp/cvs-serv18292/MacCRO X.pbproj Modified Files: project.pbxproj Log Message: Released 0.1.2 |
From: <sco...@li...> - 2003-02-20 13:07:05
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv18292 Modified Files: MacCRO X Package.pmsp ChangeLog Log Message: Released 0.1.2 Index: MacCRO X Package.pmsp =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/MacCRO X Package.pmsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsiJm8dq and /tmp/cvs672xgG differ Index: ChangeLog =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/ChangeLog,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ChangeLog 20 Feb 2003 12:56:35 -0000 1.15 --- ChangeLog 20 Feb 2003 13:07:02 -0000 1.16 *************** *** 1,4 **** --- 1,6 ---- 2003-02-20 Philip Derrin <na...@us...> + * Released 0.1.2 + * src/TestSampler.m (-createData), src/TestSampler.h: Clean up the test sampler a bit. No more random frequencies, or |
From: <sco...@li...> - 2003-02-20 12:57:23
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv12161 Modified Files: Todo.rtf Log Message: Yet another new item in the to do list. Index: Todo.rtf =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/Todo.rtf,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Todo.rtf 19 Feb 2003 06:10:48 -0000 1.9 --- Todo.rtf 20 Feb 2003 12:57:18 -0000 1.10 *************** *** 30,33 **** --- 30,34 ---- \'a5 Waterfall display.\ \'a5 Localisation for US English, maybe others\ + \'a5 Rearrange interface to work better on 1024x768 and smaller screens.\ \ \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural |
From: <sco...@li...> - 2003-02-20 12:56:41
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv11380/src Modified Files: TestSampler.h TestSampler.m Log Message: Clean up the test sampler a bit. No more random frequencies, or discontinuities in the wave at boundaries between blocks. Index: TestSampler.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/TestSampler.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestSampler.h 19 Oct 2002 06:39:31 -0000 1.7 --- TestSampler.h 20 Feb 2003 12:56:36 -0000 1.8 *************** *** 36,40 **** unsigned short myChannelCount; ! double myFrequency; NSConditionLock* myStateLock; --- 36,41 ---- unsigned short myChannelCount; ! float myFrequency; ! float myOffset; NSConditionLock* myStateLock; Index: TestSampler.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/TestSampler.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestSampler.m 5 Dec 2002 15:08:10 -0000 1.8 --- TestSampler.m 20 Feb 2003 12:56:36 -0000 1.9 *************** *** 66,72 **** mySampleRate = 44100.0; ! myFrequency = 1000.0; myChannelCount = 2; myBlockSize = 64; } --- 66,74 ---- mySampleRate = 44100.0; ! myFrequency = 538.3301; // exact multiple of block size ! // myFrequency = 3000; // not exact multiple of block size myChannelCount = 2; myBlockSize = 64; + myOffset = 0; } *************** *** 185,191 **** Sample* theData; unsigned long curSample; ! float amplitude = (float)random() / (float)INT_MAX; ! myFrequency += 10 * ((float)random() / (float)INT_MAX - 0.5); if(myOwner == nil) return self; --- 187,194 ---- Sample* theData; unsigned long curSample; ! // float amplitude = (float)random() / (float)INT_MAX; ! float amplitude = 0.4; ! // myFrequency += 10 * ((float)random() / (float)INT_MAX - 0.5); if(myOwner == nil) return self; *************** *** 193,203 **** theData = malloc(myBlockSize * myChannelCount * sizeof(Sample)); ! for(curChannel = 0; curChannel < myChannelCount; curChannel++) { ! for(curSample = 0; curSample < myBlockSize; curSample++) { theData[(curSample * myChannelCount) + curChannel] ! = sin((M_PI * 2) * ! ((float)curSample * myFrequency ! / mySampleRate)) * amplitude; } } --- 196,206 ---- theData = malloc(myBlockSize * myChannelCount * sizeof(Sample)); ! for(curSample = 0; curSample < myBlockSize; curSample++) { ! for(curChannel = 0; curChannel < myChannelCount; curChannel++) { theData[(curSample * myChannelCount) + curChannel] ! = sin(myOffset) * amplitude; } + myOffset += 2*M_PI*myFrequency / mySampleRate; + if(myOffset > 2*M_PI) myOffset -= 2*M_PI; } |
From: <sco...@li...> - 2003-02-20 12:56:41
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv11380 Modified Files: ChangeLog Log Message: Clean up the test sampler a bit. No more random frequencies, or discontinuities in the wave at boundaries between blocks. Index: ChangeLog =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/ChangeLog,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ChangeLog 20 Feb 2003 12:51:31 -0000 1.14 --- ChangeLog 20 Feb 2003 12:56:35 -0000 1.15 *************** *** 1,4 **** --- 1,8 ---- 2003-02-20 Philip Derrin <na...@us...> + * src/TestSampler.m (-createData), src/TestSampler.h: + Clean up the test sampler a bit. No more random frequencies, or + discontinuities in the wave at boundaries between blocks. + * src/TraceView.m (-mouseDown:, -savePDFImageToFile:), src/TraceView.h: |
From: <sco...@li...> - 2003-02-20 12:53:42
|
Update of /cvsroot/scopeapp/scopeapp/English.lproj/MainMenu.nib In directory sc8-pr-cvs1:/tmp/cvs-serv7305/English.lproj/MainMenu.nib Modified Files: classes.nib info.nib objects.nib Log Message: Add menu item to export to PDF (since clicking on the image is may not be sufficiently obvious). Index: classes.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/MainMenu.nib/classes.nib,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** classes.nib 5 Feb 2003 12:52:33 -0000 1.3 --- classes.nib 20 Feb 2003 12:53:37 -0000 1.4 *************** *** 6,9 **** --- 6,10 ---- orderFrontLicensePanel = id; orderFrontPreferencesPanel = id; + savePDFImage = id; }; CLASS = FirstResponder; Index: info.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/MainMenu.nib/info.nib,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** info.nib 5 Feb 2003 12:52:33 -0000 1.4 --- info.nib 20 Feb 2003 12:53:38 -0000 1.5 *************** *** 8,15 **** <dict> <key>29</key> ! <string>403 938 285 44 0 0 1280 1002 </string> </dict> <key>IBFramework Version</key> ! <string>286.0</string> <key>IBOpenObjects</key> <array> --- 8,15 ---- <dict> <key>29</key> ! <string>299 687 285 44 0 0 1024 746 </string> </dict> <key>IBFramework Version</key> ! <string>291.0</string> <key>IBOpenObjects</key> <array> *************** *** 17,21 **** </array> <key>IBSystem Version</key> ! <string>6F21</string> </dict> </plist> --- 17,21 ---- </array> <key>IBSystem Version</key> ! <string>6H28</string> </dict> </plist> Index: objects.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/MainMenu.nib/objects.nib,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvs8Uwbdu and /tmp/cvsQPwYsQ differ |
From: <sco...@li...> - 2003-02-20 12:51:35
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv5912/src Modified Files: TraceView.h TraceView.m Log Message: Move PDF-saving code into a new action method, which is called by -mouseDown. Add -acceptsFirstResponder and -acceptsFirstMouse:, both of which unconditionally return YES. Index: TraceView.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/TraceView.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TraceView.h 14 Feb 2003 11:54:23 -0000 1.10 --- TraceView.h 20 Feb 2003 12:51:32 -0000 1.11 *************** *** 85,88 **** --- 85,90 ---- -(id) updateCaptions; + -(IBAction) savePDFImage: (id) sender; + - (id)doTriggerOnData: (Sample*) inData frameCount: (unsigned long) inFrameCount Index: TraceView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/TraceView.m,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** TraceView.m 19 Feb 2003 05:55:31 -0000 1.18 --- TraceView.m 20 Feb 2003 12:51:32 -0000 1.19 *************** *** 174,206 **** if([theEvent type] == NSLeftMouseDown && [theEvent clickCount] == 1) { ! // we draw the contents of the entire window, not just the ! // current view, so the captions are included. ! NSView* view = [[self window] contentView]; ! NSData* pdfdata = ! [[view dataWithPDFInsideRect: [view bounds]] retain]; ! NSSavePanel* panel = [NSSavePanel savePanel]; ! [panel setRequiredFileType: @"pdf"]; #ifndef __APPLE__ ! // runModalForDirectory:file:relativeToWindow: works on OS X, ! // but prints a warning that it is "obsolete and will be ! // removed". Sheets are not available in GNUstep, however. ! if([panel runModalForDirectory: nil file: nil ! relativeToWindow: [self window]] == ! NSFileHandlingPanelOKButton) ! { ! [pdfdata writeToFile: [panel filename] atomically: NO]; ! } ! [pdfdata release]; #else ! [panel beginSheetForDirectory: nil file:nil ! modalForWindow: [self window] modalDelegate: self ! didEndSelector: @selector(savePanelDidEnd:returnCode: ! contextInfo:) contextInfo: pdfdata]; #endif - } } #ifdef __APPLE__ ! // This method is called by the NSSavePanel created by -mouseDown:. // contextInfo will be an NSData* containing the data to write to the // chosen file. --- 174,221 ---- if([theEvent type] == NSLeftMouseDown && [theEvent clickCount] == 1) { ! [self savePDFImage: self]; ! } ! } ! ! -(BOOL) acceptsFirstMouse: (NSEvent*) theEvent ! { ! return YES; ! } ! ! -(BOOL) acceptsFirstResponder ! { ! return YES; ! } ! ! -(IBAction) savePDFImage: (id) sender; ! { ! // we draw the contents of the entire window, not just the ! // current view, so the captions are included. ! NSView* view = [[self window] contentView]; ! NSData* pdfdata = ! [[view dataWithPDFInsideRect: [view bounds]] retain]; ! NSSavePanel* panel = [NSSavePanel savePanel]; ! [panel setRequiredFileType: @"pdf"]; #ifndef __APPLE__ ! // runModalForDirectory:file:relativeToWindow: works on OS X, ! // but prints a warning that it is "obsolete and will be ! // removed". Sheets are not available in GNUstep, however. ! if([panel runModalForDirectory: nil file: nil ! relativeToWindow: [self window]] == ! NSFileHandlingPanelOKButton) ! { ! [pdfdata writeToFile: [panel filename] atomically: NO]; ! } ! [pdfdata release]; #else ! [panel beginSheetForDirectory: nil file:nil ! modalForWindow: [self window] modalDelegate: self ! didEndSelector: @selector(savePanelDidEnd:returnCode: ! contextInfo:) contextInfo: pdfdata]; #endif } #ifdef __APPLE__ ! // This method is called by the NSSavePanel created by -savePDFImage:. // contextInfo will be an NSData* containing the data to write to the // chosen file. |
From: <sco...@li...> - 2003-02-20 12:51:35
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv5912 Modified Files: ChangeLog Log Message: Move PDF-saving code into a new action method, which is called by -mouseDown. Add -acceptsFirstResponder and -acceptsFirstMouse:, both of which unconditionally return YES. Index: ChangeLog =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/ChangeLog,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ChangeLog 19 Feb 2003 06:08:43 -0000 1.13 --- ChangeLog 20 Feb 2003 12:51:31 -0000 1.14 *************** *** 1,3 **** --- 1,23 ---- + 2003-02-20 Philip Derrin <na...@us...> + + * src/TraceView.m (-mouseDown:, -savePDFImageToFile:), + src/TraceView.h: + Move PDF-saving code into a new action method, which is called by + -mouseDown. Add -acceptsFirstResponder and -acceptsFirstMouse:, + both of which unconditionally return YES. + + * src/SpectrumView.m (-doRealFFTOnData:, -doWindowingOnData:), + src/SpectrumView.h: + Implemented several windowing functions (Bartlett, Blackman, Hamming, + Hann (aka Hanning), Welch). Change scaling again; FFT results are divided + by the area of the window function (which is N for the rectangular + window). + 2003-02-19 Philip Derrin <na...@us...> + + * src/SpectrumView.m (vsqrt(float*, int), updateDisplay:): + Fixed some more scaling bugs. FFT results are now being scaled by + 1/N instead of 1/2; this seems to contradict Apple's vDSP docs but + gives the correct results (tested with TestSampler). * src/SpectrumView.m (-doAccumulationOnData:, -doWindowingOnData:, |
From: <sco...@li...> - 2003-02-20 02:26:58
|
Update of /cvsroot/scopeapp/scopeapp/English.lproj/ScopeWindow.nib In directory sc8-pr-cvs1:/tmp/cvs-serv2607/English.lproj/ScopeWindow.nib Modified Files: info.nib objects.nib Log Message: Add newly-implemented windowing functions to spectrum analyser UI Index: info.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/ScopeWindow.nib/info.nib,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** info.nib 14 Feb 2003 11:51:48 -0000 1.8 --- info.nib 20 Feb 2003 02:26:55 -0000 1.9 *************** *** 9,14 **** <key>IBOpenObjects</key> <array> - <integer>5</integer> <integer>25</integer> </array> <key>IBSystem Version</key> --- 9,14 ---- <key>IBOpenObjects</key> <array> <integer>25</integer> + <integer>5</integer> </array> <key>IBSystem Version</key> Index: objects.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/ScopeWindow.nib/objects.nib,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 Binary files /tmp/cvswRiRIf and /tmp/cvsU9vb5k differ |
From: <sco...@li...> - 2003-02-20 02:23:01
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv1302/src Modified Files: SpectrumView.h SpectrumView.m Log Message: Implemented several windowing functions (Bartlett, Blackman, Hamming, Hann (aka Hanning), Welch). Change scaling again; FFT results are divided by the area of the window function (which is N for the rectangular window). Index: SpectrumView.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SpectrumView.h 19 Feb 2003 06:08:43 -0000 1.8 --- SpectrumView.h 20 Feb 2003 02:22:58 -0000 1.9 *************** *** 37,40 **** --- 37,45 ---- typedef enum WindowType { eWindowRectangular = 0, + eWindowBartlett, + eWindowHann, + eWindowHamming, + eWindowBlackman, + eWindowWelch, } WindowType; *************** *** 83,86 **** --- 88,92 ---- NSData* myWindowFactors; WindowType myWindowType; + float myWindowArea; NSLock* mySavedDataLock; } Index: SpectrumView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.m,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SpectrumView.m 19 Feb 2003 11:01:26 -0000 1.13 --- SpectrumView.m 20 Feb 2003 02:22:58 -0000 1.14 *************** *** 114,117 **** --- 114,119 ---- myFFTSetup = create_fftsetup(log2n, kFFTRadix2); + [self recalculateWindowWithSize: n]; + if(wasDrawing) [self startDrawing]; } else { *************** *** 214,218 **** // apply scaling factor ! scale = 1.0 / length; vsmul(real, 1, &scale, real, 1, length / 2); vsmul(imag, 1, &scale, imag, 1, length / 2); --- 216,224 ---- // apply scaling factor ! // I'm not sure that this is correct, but it gives correct results for ! // a wave with a power of 2 number of samples per cycle and ! // approximately correct (better than rectangular window) results for ! // other frequencies. ! scale = 1.0 / myWindowArea; vsmul(real, 1, &scale, real, 1, length / 2); vsmul(imag, 1, &scale, imag, 1, length / 2); *************** *** 253,257 **** --- 259,270 ---- int i, count = [data length] / sizeof(float); + if(myWindowFactors == nil || + [data length] != [myWindowFactors length]) + { + [self recalculateWindowWithSize: count]; + } + if(myWindowType == eWindowRectangular) { + // take a shortcut... return data; } *************** *** 259,271 **** newData = malloc([data length]); oldData = [data bytes]; [mySavedDataLock lock]; - if([data length] != [myWindowFactors length]) - { - [self recalculateWindowWithSize: count]; - } - factors = [myWindowFactors bytes]; - #ifdef __APPLE__ #pragma unused(i) --- 272,279 ---- newData = malloc([data length]); oldData = [data bytes]; + factors = [myWindowFactors bytes]; [mySavedDataLock lock]; #ifdef __APPLE__ #pragma unused(i) *************** *** 570,573 **** --- 578,582 ---- { float* data; + int i; if(myWindowFactors != nil) { *************** *** 577,587 **** --- 586,633 ---- if(myWindowType == eWindowRectangular) { myWindowFactors = nil; + myWindowArea = length; return self; } data = malloc(length * sizeof(float)); + myWindowArea = 0; switch(myWindowType) { + case eWindowBartlett: + for(i=0; i<length/2; i++) { + data[i] = (2.0 * i) / (length - 1); + myWindowArea += data[i]; + } + for(i=length/2; i<length; i++) { + data[i] = (2.0 * (length - i - 1)) / (length - 1); + myWindowArea += data[i]; + } + break; + case eWindowHann: + for(i=0; i<length; i++) { + data[i] = 0.5 * (1 - cos(2*M_PI*((float)i / (length - 1)))); + myWindowArea += data[i]; + } + break; + case eWindowHamming: + for(i=0; i<length; i++) { + data[i] = 0.54 - (0.46*cos(2*M_PI*((float)i / (length - 1)))); + myWindowArea += data[i]; + } + break; + case eWindowBlackman: + for(i=0; i<length; i++) { + data[i] = 0.42 - (0.5*cos(2*M_PI*((float)i / (length - 1)))) + + (0.08*cos(4*M_PI*((float)i / (length - 1)))); + myWindowArea += data[i]; + } + break; + case eWindowWelch: + for(i=0; i<length; i++) { + data[i] = 1 - pow(((float)i - (length/2))/(length/2), 2); + myWindowArea += data[i]; + } + break; default: NSLog(@"-[SpectrumView recalculateWindowWithSize:]: unknown window type"); |
From: <sco...@li...> - 2003-02-19 11:01:31
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv4751 Modified Files: SpectrumView.m Log Message: Fixed some more scaling bugs. FFT results are now being scaled by 1/N instead of 1/2; this seems to contradict Apple's vDSP docs but gives the correct results (tested with TestSampler). Index: SpectrumView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.m,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SpectrumView.m 19 Feb 2003 06:08:43 -0000 1.12 --- SpectrumView.m 19 Feb 2003 11:01:26 -0000 1.13 *************** *** 214,218 **** // apply scaling factor ! scale = 0.5; vsmul(real, 1, &scale, real, 1, length / 2); vsmul(imag, 1, &scale, imag, 1, length / 2); --- 214,218 ---- // apply scaling factor ! scale = 1.0 / length; vsmul(real, 1, &scale, real, 1, length / 2); vsmul(imag, 1, &scale, imag, 1, length / 2); *************** *** 391,395 **** // calculate the values by which frequency and magnitude must be // scaled and offset ! xoffset = -myXFrom[inTrace]; if(myXTo[inTrace] - myXFrom[inTrace] <= 0) { --- 391,395 ---- // calculate the values by which frequency and magnitude must be // scaled and offset ! xoffset = -myXFrom[inTrace] * myDataStored[inTrace] / mySampleRate; if(myXTo[inTrace] - myXFrom[inTrace] <= 0) { *************** *** 404,408 **** } ! yoffset = -myYFrom[inTrace]; if(myYTo[inTrace] - myYFrom[inTrace] <= 0) { --- 404,408 ---- } ! yoffset = -myYFrom[inTrace] / myGain; if(myYTo[inTrace] - myYFrom[inTrace] <= 0) { *************** *** 559,563 **** for(i=0; i<count; i++) { ! *data = sqrt(*data); } #endif --- 559,563 ---- for(i=0; i<count; i++) { ! data[i] = sqrt(data[i]); } #endif |
From: <sco...@li...> - 2003-02-19 06:10:51
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv15246 Modified Files: Todo.rtf Log Message: Index: Todo.rtf =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/Todo.rtf,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Todo.rtf 15 Feb 2003 12:36:48 -0000 1.8 --- Todo.rtf 19 Feb 2003 06:10:48 -0000 1.9 *************** *** 11,15 **** \f0\b Bugs to fix\ ! \f1\b0 \'a5 PortAudio fails to set the buffer size the first time MacCRO runs (on my system, using iMic).\ \'a5 Speed up display further if possible.\ \ --- 11,15 ---- \f0\b Bugs to fix\ ! \f1\b0 \'a5 PortAudio fails to set the buffer size the first time MacCRO runs (on my PowerMac G4, using an iMic). This appears to be iMic-specific, or at least not universal, because it works correctly on my 12" AlBook's internal input.\ \'a5 Speed up display further if possible.\ \ *************** *** 17,22 **** \f0\b Features to implement before beta release\ ! \f1\b0 \'a5 Spectrum analyser: accumulation, windowing\ ! \'a5 Triggering code.\ \'a5 Icon\ \'a5 Calibration option for amplitudes\ --- 17,21 ---- \f0\b Features to implement before beta release\ ! \f1\b0 \'a5 Triggering code.\ \'a5 Icon\ \'a5 Calibration option for amplitudes\ *************** *** 28,32 **** \'a5 Multiple trace windows.\ \'a5 Text file capture.\ ! \'a5 Save control settings between runs\ \ \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural --- 27,33 ---- \'a5 Multiple trace windows.\ \'a5 Text file capture.\ ! \'a5 Save control settings between runs.\ ! \'a5 Waterfall display.\ ! \'a5 Localisation for US English, maybe others\ \ \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural |
From: <sco...@li...> - 2003-02-19 06:09:28
|
Update of /cvsroot/scopeapp/scopeapp/English.lproj/ScopeWindow.nib In directory sc8-pr-cvs1:/tmp/cvs-serv14632/English.lproj/ScopeWindow.nib Modified Files: classes.nib objects.nib Log Message: Add windowing UI to spectrum analyser controls Index: classes.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/ScopeWindow.nib/classes.nib,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** classes.nib 14 Feb 2003 11:51:48 -0000 1.5 --- classes.nib 19 Feb 2003 06:09:25 -0000 1.6 *************** *** 50,53 **** --- 50,54 ---- changedFreqScale = id; changedVoltScale = id; + changedWindowingSettings = id; }; CLASS = SpectrumView; *************** *** 66,69 **** --- 67,71 ---- myShowScaleCheckbox = NSButton; myShowTimeCheckbox = NSButton; + myWindowTypeMenu = NSPopUpButton; }; SUPERCLASS = TraceView; Index: objects.nib =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/English.lproj/ScopeWindow.nib/objects.nib,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 Binary files /tmp/cvsnYtVUT and /tmp/cvskoR2RF differ |
From: <sco...@li...> - 2003-02-19 06:08:46
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv12581 Modified Files: ChangeLog Log Message: Implemented windowing and accumulation. No actual windowing functions have been added yet, but the framework is done. Index: ChangeLog =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/ChangeLog,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ChangeLog 18 Feb 2003 12:06:18 -0000 1.12 --- ChangeLog 19 Feb 2003 06:08:43 -0000 1.13 *************** *** 1,2 **** --- 1,16 ---- + 2003-02-19 Philip Derrin <na...@us...> + + * src/SpectrumView.m (-doAccumulationOnData:, -doWindowingOnData:, + -changedAccumulationSettings:, -changedWindowingSettings:, + -recalculateWindowWithSize:): + Implement accumulation and windowing. No actual windowing functions + have been added yet, but the framework is done. + + * src/SpectrumView.h: + Add outlet for a menu to control windowing; add member variables + for accumulation and windowing. + + * src/TraceView.m (-drawRect:): Disable old debugging code + 2003-02-18 Philip Derrin <na...@us...> |
From: <sco...@li...> - 2003-02-19 06:08:46
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv12581/src Modified Files: SpectrumView.h SpectrumView.m Log Message: Implemented windowing and accumulation. No actual windowing functions have been added yet, but the framework is done. Index: SpectrumView.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SpectrumView.h 18 Feb 2003 12:06:19 -0000 1.7 --- SpectrumView.h 19 Feb 2003 06:08:43 -0000 1.8 *************** *** 35,38 **** --- 35,41 ---- #import "TraceView.h" + typedef enum WindowType { + eWindowRectangular = 0, + } WindowType; @interface SpectrumView : TraceView { *************** *** 53,56 **** --- 56,62 ---- IBOutlet NSButton* myAccumulateCheckbox; IBOutlet NSButton* myAccumulateReset; + + // Windowing settings + IBOutlet NSPopUpButton* myWindowTypeMenu; // display settings *************** *** 63,67 **** double myXTo[2], myYTo[2]; BOOL myXIsLog, myYIsLog; - int myWindowType; double myGain; --- 69,72 ---- *************** *** 72,75 **** --- 77,87 ---- FFTSetup myFFTSetup; #endif + + // Data for accumulation and windowing + NSMutableData* myAccumulatedData[2]; + int myAccumulationCount[2]; // -1 if disabled + NSData* myWindowFactors; + WindowType myWindowType; + NSLock* mySavedDataLock; } *************** *** 88,92 **** -(NSData*) doWindowingOnData: (NSData*) data; ! -(NSData*) doAccumulationOnData: (NSData*) data; @end --- 100,104 ---- -(NSData*) doWindowingOnData: (NSData*) data; ! -(NSData*) doAccumulationOnData: (NSData*) data fromTrace: (int) trace; @end Index: SpectrumView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.m,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SpectrumView.m 18 Feb 2003 12:06:19 -0000 1.11 --- SpectrumView.m 19 Feb 2003 06:08:43 -0000 1.12 *************** *** 39,42 **** --- 39,48 ---- #endif + @interface SpectrumView (SpectrumViewInternal) + + - recalculateWindowWithSize: (int) length; + + @end + @implementation SpectrumView *************** *** 53,56 **** --- 59,70 ---- myXTo[1] = 0.0; myYTo[1] = 0.0; + myXIsLog = NO; + myYIsLog = NO; + myWindowType = eWindowRectangular; + myShowScales = NO; + myAccumulatedData[0] = myAccumulatedData[1] = nil; + myAccumulationCount[0] = myAccumulationCount[1] = -1; + myWindowFactors = nil; + mySavedDataLock = [[NSLock alloc] init]; myFFTSetup = create_fftsetup(12, kFFTRadix2); *************** *** 64,67 **** --- 78,89 ---- destroy_fftsetup(myFFTSetup); + + [mySavedDataLock lock]; + if(myAccumulatedData[0]) { [myAccumulatedData[0] release]; } + if(myAccumulatedData[1]) { [myAccumulatedData[1] release]; } + if(myWindowFactors) { [myWindowFactors release]; } + [mySavedDataLock unlock]; + + [mySavedDataLock release]; [super dealloc]; *************** *** 138,150 **** -(IBAction) changedAccumulationSettings: (id) sender { ! // FIXME implement accumulation! } -(IBAction) changedWindowingSettings: (id) sender { ! // FIXME implement windowing! } ! -(NSData*) doRealFFTForData: (NSData*) data; { #if defined(__APPLE__) --- 160,190 ---- -(IBAction) changedAccumulationSettings: (id) sender { ! [mySavedDataLock lock]; ! if(sender == myAccumulateReset) { ! myAccumulationCount[0] = 0; ! myAccumulationCount[1] = 0; ! } else if([myAccumulateCheckbox state] == NSOffState) { ! myAccumulationCount[0] = -1; ! myAccumulationCount[1] = -1; ! } else { ! myAccumulationCount[0] = 0; ! myAccumulationCount[1] = 0; ! } ! [mySavedDataLock unlock]; } -(IBAction) changedWindowingSettings: (id) sender { ! myWindowType = [myWindowTypeMenu indexOfSelectedItem]; ! ! [mySavedDataLock lock]; ! if(myWindowFactors != nil) { ! [myWindowFactors release]; ! myWindowFactors = nil; ! } ! [mySavedDataLock unlock]; } ! -(NSData*) doRealFFTForData: (NSData*) data { #if defined(__APPLE__) *************** *** 196,200 **** free(imag); ! return [NSData dataWithBytesNoCopy: magnitudes length: ((length / 2) + 1) * sizeof(float) freeWhenDone: YES]; --- 236,242 ---- free(imag); ! [data release]; ! ! return [[NSData alloc] initWithBytesNoCopy: magnitudes length: ((length / 2) + 1) * sizeof(float) freeWhenDone: YES]; *************** *** 206,215 **** -(NSData*) doWindowingOnData: (NSData*) data { ! return data; } ! -(NSData*) doAccumulationOnData: (NSData*) data { ! return data; } --- 248,339 ---- -(NSData*) doWindowingOnData: (NSData*) data { ! float *newData; ! const float *oldData; ! const float *factors; ! int i, count = [data length] / sizeof(float); ! ! if(myWindowType == eWindowRectangular) { ! return data; ! } ! ! newData = malloc([data length]); ! oldData = [data bytes]; ! ! [mySavedDataLock lock]; ! ! if([data length] != [myWindowFactors length]) ! { ! [self recalculateWindowWithSize: count]; ! } ! factors = [myWindowFactors bytes]; ! ! #ifdef __APPLE__ ! #pragma unused(i) ! vmul(factors, 1, oldData, 1, newData, 1, count); ! #else ! for(i=0; i<count; i++) { ! newData[i] = factors[i] * oldData[i]; ! } ! #endif ! [mySavedDataLock unlock]; ! ! [data release]; ! ! return [[NSData alloc] initWithBytesNoCopy: newData ! length: count * sizeof(float) freeWhenDone: YES]; } ! -(NSData*) doAccumulationOnData: (NSData*) data fromTrace: (int) trace { ! if(myAccumulationCount[trace] < 0) { ! return data; ! } ! ! [mySavedDataLock lock]; ! ! if(myAccumulatedData[trace] == nil || ! myAccumulationCount[trace] == 0 || ! [myAccumulatedData[trace] length] != [data length]) ! { ! myAccumulationCount[trace] = 1; ! if(myAccumulatedData[trace]) { ! [myAccumulatedData[trace] release]; ! } ! myAccumulatedData[trace] = ! [[NSMutableData alloc] initWithData: data]; ! } else { ! float *newData; ! const float *oldData; ! float f; ! int count, i; ! ! newData = [myAccumulatedData[trace] mutableBytes]; ! oldData = [data bytes]; ! count = [data length] / sizeof(float); ! ! #ifdef __APPLE__ ! #pragma unused(i) ! f = myAccumulationCount[trace]; ! vsmul(newData, 1, &f, newData, 1, count); ! vadd(newData, 1, oldData, 1, newData, 1, count); ! f = 1.0 / (float)++myAccumulationCount[trace]; ! vsmul(newData, 1, &f, newData, 1, count); ! #else ! #pragma unused(f) ! for(i=0; i<count; i++) ! { ! newData[i] = (oldData[i] + ! (myAccumulationCount[trace] * newData[i])) ! / (float)(myAccumulationCount[trace] + 1); ! } ! myAccumulationCount[trace]++; ! #endif ! } ! ! [mySavedDataLock unlock]; ! ! [data release]; ! ! return (NSData*)[myAccumulatedData[trace] retain]; } *************** *** 240,243 **** --- 364,368 ---- [self changedVoltScale: self]; [self changedAccumulationSettings: self]; + [self changedWindowingSettings: self]; return self; *************** *** 255,270 **** if(inTrace) return self; ! data = [NSData dataWithBytesNoCopy: myDisplayData[inTrace] length: myDataStored[inTrace] * sizeof(float) freeWhenDone: NO]; data = [self doWindowingOnData: data]; data = [self doRealFFTForData: data]; ! data = [self doAccumulationOnData: data]; magnitudes = [data bytes]; count = [data length] / sizeof(float); ! ! [myDisplayLock lock]; ! [myTracePaths[inTrace] removeAllPoints]; ! // calculate the values by which frequency and magnitude must be // scaled and offset --- 380,392 ---- if(inTrace) return self; ! data = [[NSData alloc] initWithBytesNoCopy: myDisplayData[inTrace] length: myDataStored[inTrace] * sizeof(float) freeWhenDone: NO]; data = [self doWindowingOnData: data]; data = [self doRealFFTForData: data]; ! data = [self doAccumulationOnData: data fromTrace: inTrace]; magnitudes = [data bytes]; count = [data length] / sizeof(float); ! // calculate the values by which frequency and magnitude must be // scaled and offset *************** *** 299,302 **** --- 421,427 ---- // FIXME if X is logarithmic, the 0th point will have an x-coordinate of -inf, // which Quartz will silently fail to draw. + + [myDisplayLock lock]; + [myTracePaths[inTrace] removeAllPoints]; for(i = istart; i < count; i++) { *************** *** 310,313 **** --- 435,440 ---- [myDisplayLock unlock]; + + [data release]; return self; *************** *** 406,411 **** void vsqrt(float* data, int count) { ! #if 0 ! __vector__ float *vdata; while(((unsigned int)data % 16) && count) { --- 533,539 ---- void vsqrt(float* data, int count) { ! #if __VEC__ ! // This code requires compilation with -faltivec ! vector float *vdata; while(((unsigned int)data % 16) && count) { *************** *** 436,439 **** --- 564,601 ---- } #endif + + @implementation SpectrumView (SpectrumViewInternal) + + - recalculateWindowWithSize: (int) length; + { + float* data; + + if(myWindowFactors != nil) { + [myWindowFactors release]; + } + + if(myWindowType == eWindowRectangular) { + myWindowFactors = nil; + return self; + } + + data = malloc(length * sizeof(float)); + + switch(myWindowType) + { + default: + NSLog(@"-[SpectrumView recalculateWindowWithSize:]: unknown window type"); + break; + } + + myWindowFactors = [[NSData alloc] initWithBytesNoCopy: data + length: length * sizeof(float) + freeWhenDone: YES]; + + return self; + } + + @end + // vim:syn=objc:inde=: |
From: <sco...@li...> - 2003-02-19 05:55:36
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv10360/src Modified Files: TraceView.m Log Message: Disable old debugging code Index: TraceView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/TraceView.m,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** TraceView.m 18 Feb 2003 12:02:41 -0000 1.17 --- TraceView.m 19 Feb 2003 05:55:31 -0000 1.18 *************** *** 104,108 **** - (void)drawRect:(NSRect)rect { ! #ifdef DEBUG_CODE NSDate* startTime; NSTimeInterval time; --- 104,108 ---- - (void)drawRect:(NSRect)rect { ! #if 0 NSDate* startTime; NSTimeInterval time; *************** *** 130,134 **** // lock the display data [myDisplayLock lock]; ! #ifdef DEBUG_CODE startTime = [NSDate date]; #endif --- 130,134 ---- // lock the display data [myDisplayLock lock]; ! #if 0 startTime = [NSDate date]; #endif *************** *** 160,164 **** [context setShouldAntialias: wasAntiAliased]; ! #ifdef DEBUG_CODE time = -[startTime timeIntervalSinceNow]; fprintf(stderr, "%d %lf\n", myDataWanted[0], time); --- 160,164 ---- [context setShouldAntialias: wasAntiAliased]; ! #if 0 time = -[startTime timeIntervalSinceNow]; fprintf(stderr, "%d %lf\n", myDataWanted[0], time); |
From: <sco...@li...> - 2003-02-18 12:06:22
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv12943/src Modified Files: SpectrumView.h SpectrumView.m Log Message: Separate the FFT code into a new method which operates on NSData objects; add new methods for handling accumulation & windowing (currently stubs) Index: SpectrumView.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SpectrumView.h 14 Feb 2003 11:55:16 -0000 1.6 --- SpectrumView.h 18 Feb 2003 12:06:19 -0000 1.7 *************** *** 63,66 **** --- 63,67 ---- double myXTo[2], myYTo[2]; BOOL myXIsLog, myYIsLog; + int myWindowType; double myGain; *************** *** 79,83 **** --- 80,92 ---- -(IBAction) changedAccumulationSettings: (id) sender; + -(IBAction) changedWindowingSettings: (id) sender; + -(IBAction) changedDisplaySettings: (id) sender; + + -(NSData*) doRealFFTForData: (NSData*) data; + + -(NSData*) doWindowingOnData: (NSData*) data; + + -(NSData*) doAccumulationOnData: (NSData*) data; @end Index: SpectrumView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/SpectrumView.m,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SpectrumView.m 14 Feb 2003 11:57:33 -0000 1.10 --- SpectrumView.m 18 Feb 2003 12:06:19 -0000 1.11 *************** *** 32,35 **** --- 32,42 ---- #define kResolutionMenuOffset 9 + #ifdef __APPLE__ + #include <vecLib/vDSP.h> + #include <vecLib/vfp.h> + + void vsqrt(float* data, int count); + #endif + @implementation SpectrumView *************** *** 134,137 **** --- 141,217 ---- } + -(IBAction) changedWindowingSettings: (id) sender + { + // FIXME implement windowing! + } + + -(NSData*) doRealFFTForData: (NSData*) data; + { + #if defined(__APPLE__) + float *real, *imag; + float *magnitudes; + DSPSplitComplex splitdata; + float scale; + float temp; + int length; + + length = [data length] / sizeof(float); + + // first allocate some temporary space + real = malloc(sizeof(float) * length / 2); + imag = malloc(sizeof(float) * length / 2); + + // do fft using Apple's vecLib routines + splitdata.realp = real; + splitdata.imagp = imag; + + // split the data into even-odd array + ctoz((DSPComplex*)[data bytes], 2, + &splitdata, 1, length / 2); + + // run the transform + fft_zrip(myFFTSetup, &splitdata, 1, log2(length), FFT_FORWARD); + + // apply scaling factor + scale = 0.5; + vsmul(real, 1, &scale, real, 1, length / 2); + vsmul(imag, 1, &scale, imag, 1, length / 2); + + // imag[0] really contains real[n/2]. Set it to 0 so it doesn't get in + // the way when calculating magnitudes. + temp = imag[0]; + imag[0] = 0.0; + + // now calculate the magnitudes. + magnitudes = malloc((length / 2 + 1) * sizeof(float)); + vmul(real, 1, real, 1, real, 1, length / 2); + vmul(imag, 1, imag, 1, imag, 1, length / 2); + vadd(real, 1, imag, 1, magnitudes, 1, length / 2); + vsqrt(magnitudes, length / 2); + + // copy real[n/2] back + magnitudes[length/2] = temp; + + free(real); + free(imag); + + return [NSData dataWithBytesNoCopy: magnitudes + length: ((length / 2) + 1) * sizeof(float) + freeWhenDone: YES]; + #else + #error FIXME FFT not implemented on this platform + #endif + } + + -(NSData*) doWindowingOnData: (NSData*) data + { + return data; + } + + -(NSData*) doAccumulationOnData: (NSData*) data + { + return data; + } + // FIXME implement this function to set the controls appropriately from // default / saved values *************** *** 168,211 **** float curX, curY; float xscale, yscale, xoffset, yoffset; ! int i, istart; ! float *real, *imag; ! #if defined(__APPLE__) ! DSPSplitComplex data; ! float scale; ! #endif // FIXME implement split-screen display for two channels? if(inTrace) return self; - - // first allocate some temporary space - real = malloc(sizeof(float) * myDataStored[inTrace] / 2); - imag = malloc(sizeof(float) * myDataStored[inTrace] / 2); - - // FIXME do windowing here - - #if defined(__APPLE__) - // do fft using Apple's vecLib routines - data.realp = real; - data.imagp = imag; - - // split the data into even-odd array - ctoz((DSPComplex*)myDisplayData[inTrace], 2, - &data, 1, myDataStored[inTrace] / 2); - - // run the transform - fft_zrip(myFFTSetup, &data, 1, log2(myDataStored[inTrace]), FFT_FORWARD); ! // apply scaling factor ! scale = 0.5; ! vsmul(real, 1, &scale, real, 1, myDataStored[inTrace] / 2); ! vsmul(imag, 1, &scale, imag, 1, myDataStored[inTrace] / 2); - // imag[0] really contains real[n/2]. Set it to 0 so it doesn't get in - // the way in the loop below. - imag[0] = 0; - #else - #error FIXME FFT not implemented on this platform - #endif - [myDisplayLock lock]; [myTracePaths[inTrace] removeAllPoints]; --- 248,267 ---- float curX, curY; float xscale, yscale, xoffset, yoffset; ! int i, istart, count; ! NSData* data; ! const float* magnitudes; // FIXME implement split-screen display for two channels? if(inTrace) return self; ! data = [NSData dataWithBytesNoCopy: myDisplayData[inTrace] ! length: myDataStored[inTrace] * sizeof(float) ! freeWhenDone: NO]; ! data = [self doWindowingOnData: data]; ! data = [self doRealFFTForData: data]; ! data = [self doAccumulationOnData: data]; ! magnitudes = [data bytes]; ! count = [data length] / sizeof(float); [myDisplayLock lock]; [myTracePaths[inTrace] removeAllPoints]; *************** *** 244,249 **** // which Quartz will silently fail to draw. ! for(i = istart; i < myDataStored[inTrace] / 2; i++) { ! double m = sqrt(real[i] * real[i] + imag[i] * imag[i]); curX = ((myXIsLog ? log10(i) : i) + xoffset) * xscale; curY = ((myYIsLog ? log10(m) : m) + yoffset) * yscale; --- 300,305 ---- // which Quartz will silently fail to draw. ! for(i = istart; i < count; i++) { ! float m = magnitudes[i]; curX = ((myXIsLog ? log10(i) : i) + xoffset) * xscale; curY = ((myYIsLog ? log10(m) : m) + yoffset) * yscale; *************** *** 255,261 **** [myDisplayLock unlock]; - free(real); - free(imag); - return self; } --- 311,314 ---- *************** *** 349,352 **** --- 402,439 ---- @end + + #ifdef __APPLE__ + void vsqrt(float* data, int count) + { + #if 0 + __vector__ float *vdata; + while(((unsigned int)data % 16) && count) + { + *data = sqrt(*data); + count--; + data++; + } + vdata = (vector float*)data; + while(count >= 4) + { + *vdata = vsqrtf(*vdata); + count -= 4; + vdata++; + } + while(count) + { + *data = sqrt(*data); + count--; + data++; + } + #else + int i; + for(i=0; i<count; i++) + { + *data = sqrt(*data); + } + #endif + } + #endif // vim:syn=objc:inde=: |
From: <sco...@li...> - 2003-02-18 12:06:22
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv12943 Modified Files: ChangeLog Log Message: Separate the FFT code into a new method which operates on NSData objects; add new methods for handling accumulation & windowing (currently stubs) Index: ChangeLog =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/ChangeLog,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ChangeLog 18 Feb 2003 12:02:41 -0000 1.11 --- ChangeLog 18 Feb 2003 12:06:18 -0000 1.12 *************** *** 1,4 **** --- 1,9 ---- 2003-02-18 Philip Derrin <na...@us...> + * src/SpectrumView.h, src/SpectrumView.m: + Separate the FFT code into a new method that operates on NSData + objects; add new methods (currently stubs) for accumulation & + windowing + * src/TraceView.m (-displayThread:): Release and replace the autorelease pool every time around the |
From: <sco...@li...> - 2003-02-18 12:02:45
|
Update of /cvsroot/scopeapp/scopeapp/src In directory sc8-pr-cvs1:/tmp/cvs-serv11460/src Modified Files: TraceView.m Log Message: Release and replace the autorelease pool every time around the display thread's loop Index: TraceView.m =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/TraceView.m,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TraceView.m 16 Feb 2003 01:23:26 -0000 1.16 --- TraceView.m 18 Feb 2003 12:02:41 -0000 1.17 *************** *** 474,478 **** { NSAutoreleasePool *pool; - pool = [[NSAutoreleasePool alloc] init]; [myDrawThreadState lockWhenCondition: kDrawThreadRunning]; --- 474,477 ---- *************** *** 480,483 **** --- 479,484 ---- while(myDrawThreadShouldRun) { + pool = [[NSAutoreleasePool alloc] init]; + [myDataLock lockWhenCondition: kHaveRequiredData]; [self cycleBuffers]; *************** *** 488,491 **** --- 489,494 ---- [self display]; + + [pool release]; } |
From: <sco...@li...> - 2003-02-18 12:02:44
|
Update of /cvsroot/scopeapp/scopeapp In directory sc8-pr-cvs1:/tmp/cvs-serv11460 Modified Files: ChangeLog Log Message: Release and replace the autorelease pool every time around the display thread's loop Index: ChangeLog =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/ChangeLog,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ChangeLog 16 Feb 2003 01:23:26 -0000 1.10 --- ChangeLog 18 Feb 2003 12:02:41 -0000 1.11 *************** *** 1,2 **** --- 1,8 ---- + 2003-02-18 Philip Derrin <na...@us...> + + * src/TraceView.m (-displayThread:): + Release and replace the autorelease pool every time around the + display thread's loop + 2003-02-16 Philip Derrin <na...@us...> |
From: <sco...@li...> - 2003-02-16 01:24:30
|
Update of /cvsroot/scopeapp/scopeapp/MacCRO X.pbproj In directory sc8-pr-cvs1:/tmp/cvs-serv307/MacCRO X.pbproj Modified Files: project.pbxproj Log Message: Fixed another path (was absolute, should have been relative) |