• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
MusicTrackNewUserEvent in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:

func MusicTrackNewUserEvent(_ inTrack: MusicTrack, _ inTimeStamp: MusicTimeStamp, _ inUserData: UnsafePointer<MusicEventUserData>) -> OSStatus


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.
 

Thanks,

--
GW Rodriguez

 _______________________________________________
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

  • Follow-Ups:
    • Re: MusicTrackNewUserEvent in Swift
      • From: Matt Grippaldi <email@hidden>
  • Prev by Date: Dynamic audio unit app extensions
  • Next by Date: Re: MusicTrackNewUserEvent in Swift
  • Previous by thread: Dynamic audio unit app extensions
  • Next by thread: Re: MusicTrackNewUserEvent in Swift
  • Index(es):
    • Date
    • Thread