mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
More sound stuff. Also some change to allow preferences to affect matrix size universally.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19233 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9358afe12b
commit
c68cb685cd
11 changed files with 115 additions and 4 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,4 +1,15 @@
|
|||
2004-05-01 17:40 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
2004-05-02 18:35 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormImageEditor.m: Added code to allow it to resize the cells
|
||||
in the matrix according to the setting in preferences.
|
||||
* GormSoundEditor.m: Added code to allow it to resize the cells
|
||||
in the matrix according to the setting in preferences.
|
||||
* GormSoundView.m: Commented out some of the sound drawing code.
|
||||
I'm planning on getting this working later.
|
||||
* GormSoundInspector.gorm: Added images in buttons, rw.tiff,
|
||||
rec.tiff, play.tiff, pause.tiff, and ff.tiff.
|
||||
|
||||
2004-05-02 23:40 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: [GormDocument openEditorForObject:]
|
||||
Do not bring the editor to the front if it's for an NSMenu.
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "GormPrivate.h"
|
||||
#include "GormFunctions.h"
|
||||
|
||||
/*
|
||||
* Method to return the image that should be used to display objects within
|
||||
|
@ -169,7 +170,13 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
}
|
||||
|
||||
- (void) handleNotification: (NSNotification*)aNotification
|
||||
{
|
||||
{
|
||||
NSString *name = [aNotification name];
|
||||
if([name isEqual: GormResizeCellNotification])
|
||||
{
|
||||
NSDebugLog(@"Recieved notification");
|
||||
[self setCellSize: defaultCellSize()];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -220,6 +227,13 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
RELEASE(proto);
|
||||
NSMapInsert(docMap, (void*)aDocument, (void*)self);
|
||||
[self addObject: anObject];
|
||||
|
||||
// set up the notification...
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: GormResizeCellNotification
|
||||
object: nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "GormPrivate.h"
|
||||
#include "GormFunctions.h"
|
||||
#include <AppKit/NSSound.h>
|
||||
|
||||
/*
|
||||
|
@ -169,6 +170,12 @@ static NSMapTable *docMap = 0;
|
|||
|
||||
- (void) handleNotification: (NSNotification*)aNotification
|
||||
{
|
||||
NSString *name = [aNotification name];
|
||||
if([name isEqual: GormResizeCellNotification])
|
||||
{
|
||||
NSDebugLog(@"Recieved notification");
|
||||
[self setCellSize: defaultCellSize()];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -219,6 +226,13 @@ static NSMapTable *docMap = 0;
|
|||
RELEASE(proto);
|
||||
NSMapInsert(docMap, (void*)aDocument, (void*)self);
|
||||
[self addObject: anObject];
|
||||
|
||||
// set up the notification...
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: GormResizeCellNotification
|
||||
object: nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,39 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "GormSoundView.h"
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
||||
// add a data method to the NSSound class...
|
||||
@interface NSSound (SoundView)
|
||||
- (NSData *)data;
|
||||
@end
|
||||
|
||||
@implementation NSSound (SoundView)
|
||||
- (NSData *)data
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
@end
|
||||
|
||||
static float findMax(NSData *data)
|
||||
{
|
||||
float max = 0.0;
|
||||
int index = 0;
|
||||
float *array = (float *)[data bytes];
|
||||
int len = [data length];
|
||||
|
||||
// find the maximum...
|
||||
for(index = 0; index < len; index++)
|
||||
{
|
||||
float d = array[index];
|
||||
if(d > max)
|
||||
{
|
||||
max = d;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
@implementation GormSoundView
|
||||
- (void) setSound: (NSSound *)sound
|
||||
|
@ -42,9 +75,48 @@
|
|||
return _sound;
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) drawRect: (NSRect)aRect
|
||||
{
|
||||
[super drawRect: aRect];
|
||||
}
|
||||
float w = aRect.size.width;
|
||||
float h = aRect.size.height;
|
||||
float offset = (h/2);
|
||||
NSData *soundData = [_sound data];
|
||||
float *data = 0;
|
||||
float x1 = 0, x2 = 0, y1 = offset, y2 = offset;
|
||||
float max = findMax(soundData);
|
||||
float multiplier = h/max;
|
||||
int length = [soundData length];
|
||||
int index = 0;
|
||||
int step = (length/(int)w);
|
||||
|
||||
[super drawRect: aRect];
|
||||
|
||||
PSsetrgbcolor(1.0,0,0); // red
|
||||
data = (float *)[soundData bytes];
|
||||
|
||||
if( length > 2 )
|
||||
{
|
||||
|
||||
x1 = (data[0] * multiplier);
|
||||
y1 = offset;
|
||||
for(index = step; index < w; index+=step)
|
||||
{
|
||||
int i = (int)index;
|
||||
float d = data[i];
|
||||
|
||||
// calc new position...
|
||||
x2 = d * multiplier;
|
||||
y2 = index + offset;
|
||||
|
||||
PSmoveto(x1,y1);
|
||||
PSlineto(x2,y2);
|
||||
|
||||
// move to old vars...
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@end
|
||||
|
|
BIN
Resources/GormSoundInspector.gorm/ff.tiff
Normal file
BIN
Resources/GormSoundInspector.gorm/ff.tiff
Normal file
Binary file not shown.
Binary file not shown.
BIN
Resources/GormSoundInspector.gorm/pause.tiff
Normal file
BIN
Resources/GormSoundInspector.gorm/pause.tiff
Normal file
Binary file not shown.
BIN
Resources/GormSoundInspector.gorm/play.tiff
Normal file
BIN
Resources/GormSoundInspector.gorm/play.tiff
Normal file
Binary file not shown.
BIN
Resources/GormSoundInspector.gorm/rec.tiff
Normal file
BIN
Resources/GormSoundInspector.gorm/rec.tiff
Normal file
Binary file not shown.
BIN
Resources/GormSoundInspector.gorm/rw.tiff
Normal file
BIN
Resources/GormSoundInspector.gorm/rw.tiff
Normal file
Binary file not shown.
BIN
Resources/GormSoundInspector.gorm/stop.tiff
Normal file
BIN
Resources/GormSoundInspector.gorm/stop.tiff
Normal file
Binary file not shown.
Loading…
Reference in a new issue