MusicTrackNewUserEvent in Swift
MusicTrackNewUserEvent in Swift
- Subject: MusicTrackNewUserEvent in Swift
- From: GW Rodriguez <email@hidden>
- Date: Mon, 29 Aug 2016 13:12:24 -0500
Hi all,
I’m working on an app in OS X using Swift and having trouble with the MusicPlayer API.
The MusicTrackNewUserEvent is defined as:
A MusicEventUserData is defined as:
struct MusicEventUserData { var length: UInt32 var data: (UInt8) init() init(length length : UInt32, data data : (UInt8)) }
It’s my understanding that this is a C style trick where I can define my own structure and pass it into the MusicTrackNewUserEvent function. So I defined a structure:
struct EventPlayer { var length = UInt32(sizeof(EventPlayer)) let stack: Something init (x: Something) {self.stack = x} }
I can, at least I believe because there are no errors, create a new event like so:
var a = Something() var data = "">EventPlayer(x: a) withUnsafePointer(&data) {pointer in let dataPtr = UnsafePointer<MusicEventUserData>(pointer) MusicTrackNewUserEvent(track, 1.0, dataPtr) }
Here’s the problem I have though: the MusicSequenceUserCallback (which I created and passed into the sequencer just fine) has an argument data: UnsafePointer<MusicEventUserData> I am not sure how to convert that into my custom structure EventPlayer. Any help would be really appreciated, a google search on most CoreAudio questions for Swift result in only 5 hits.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden