From e28e10045bea6b6be697c30a30aef8c888be3868 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sun, 8 Oct 2006 05:57:36 +0000 Subject: [PATCH] Nonblocking sound --- Sources/VLSoundSched.h | 17 +++++++++++++++++ Sources/VLSoundSched.mm | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Sources/VLSoundSched.h create mode 100644 Sources/VLSoundSched.mm diff --git a/Sources/VLSoundSched.h b/Sources/VLSoundSched.h new file mode 100644 index 0000000..03c4a2c --- /dev/null +++ b/Sources/VLSoundSched.h @@ -0,0 +1,17 @@ +// +// VLSoundSched.h +// Vocalese +// +// Created by Matthias Neeracher on 10/7/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import + +@interface VLSoundSched : NSObject { +} + ++ (void) setup; ++ (void) performSoundEvent:(id)soundEvent; + +@end diff --git a/Sources/VLSoundSched.mm b/Sources/VLSoundSched.mm new file mode 100644 index 0000000..6f8aa1d --- /dev/null +++ b/Sources/VLSoundSched.mm @@ -0,0 +1,35 @@ +// +// VLSoundSched.mm +// Vocalese +// +// Created by Matthias Neeracher on 10/7/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import "VLSoundSched.h" +#import "VLSoundOut.h" + +class VLSS: public VLSoundScheduler { + virtual void Schedule(VLSoundEvent * what, float when); +}; + +void VLSS::Schedule(VLSoundEvent * what, float when) +{ + [[VLSoundSched class] performSelector:@selector(performSoundEvent:) + withObject:[NSNumber numberWithUnsignedLong:(unsigned long)what] + afterDelay:when]; +} + +@implementation VLSoundSched + ++ (void) setup +{ + VLSoundOut::SetScheduler(new VLSS); +} + ++ (void) performSoundEvent:(id)soundEvent +{ + ((VLSoundEvent *)[soundEvent unsignedLongValue])->Perform(); +} + +@end