• 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
RE: Crash playing through DLSMusicDevice with large sound fonts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Crash playing through DLSMusicDevice with large sound fonts


  • Subject: RE: Crash playing through DLSMusicDevice with large sound fonts
  • From: Yasir Assam <email@hidden>
  • Date: Thu, 26 Jun 2003 08:43:17 +1000

I'm afraid I'm a bit confused here. You say:

"The best thing to do is install a pre-render notification callback and
submit all MIDI events pertaining to the next buffer in the pre-render
callback."

but I thought I was doing this. If you look at my sample code (ignoring the
name of the function):

OSStatus RenderCallback( void* ref,
AudioUnitRenderActionFlags flags,
const AudioTimeStamp*,
UInt32 bus,
UInt32 numFrames,
AudioBufferList* bufList)
{
if (ref && (flags & kAudioUnitRenderAction_PreRender)) {
// Loop through all events that need to be played now
while (moreEvents) {
MusicDeviceMIDIEvent(dev, status, byte1, byte2, 0);
//...code left out
}
}
return noErr;
}

you'll notice that I only call MusicDeviceMIDIEvent when the
kAudioUnitRenderAction_PreRender is on. So I assume this will only execute
before it renders the next buffer. Isn't this what you mean?

I only do this because I was told about a month back in this list that this
is what I should do to avoid the stuck notes bug (which we were still
getting in 10.2.6 for some strange reason).

If I've misunderstood this, I'd really appreciate a short sample or
pseudo-code telling me what to do.

Thanks,
Yasir


> -----Original Message-----
> From: Chris Reed [mailto:email@hidden]
> Sent: Thursday, 26 June 2003 5:43 AM
> To: Robert Grant
> Cc: Yasir Assam; email@hidden
> Subject: Re: Crash playing through DLSMusicDevice with large sound fonts
>
>
>
> On Wednesday, Jun 25, 2003, at 09:36 US/Central, Robert Grant wrote:
>
> > Hi Yasir,
> >
> > I'm guessing here but I don't think you should be submitting
> > MIDIEvents in the RenderCallback. The RenderNotification is happening
> > on the realtime thread and my guess is that the MIDIEvents are taking
> > too long... Why not submit the events from a non-render thread and
> > thus let the MusicDevice process them when it's ready?
> >
>
> That's correct. You shouldn't send MIDIEvents to the AU during the
> RenderCallback. The best thing to do is install a pre-render
> notification callback and submit all MIDI events pertaining to the next
> buffer in the pre-render callback.
>
> -chris
>
> > Robert.
> >
> > On Wednesday, June 25, 2003, at 04:58AM, Yasir Assam
> > <email@hidden> wrote:
> >
> >> Hi,
> >>
> >> My code crashes when playing DLSMusicDevice using a particular large
> >> sound
> >> font (the .sft2 in question is approximately 84MB). The same MIDI file
> >> played through other OS X apps that use DLSMusicDevice don't crash
> >> when
> >> played through this sound font, so I don't think the sound font is at
> >> fault.
> >>
> >> Oddly, when I set the CPU load (using kAudioUnitProperty_CPULoad) to
> >> values
> >> <= 0.7 the crash goes away, so it seems connected to how much CPU
> >> time the
> >> DLSMusicDevice uses.
> >>
> >> Rendering is pretty simple. After initialization I call:
> >>
> >> AudioUnitSetRenderNotification(dev, RenderCallback, 0);
> >>
> >> and then the render notification callback is:
> >>
> >> OSStatus RenderCallback( void* ref,
> >> AudioUnitRenderActionFlags flags,
> >> const AudioTimeStamp*,
> >> UInt32 bus,
> >> UInt32 numFrames,
> >> AudioBufferList* bufList)
> >> {
> >> if (ref && (flags & kAudioUnitRenderAction_PreRender)) {
> >> // Loop through all events that need to be played now
> >> while (moreEvents) {
> >> MusicDeviceMIDIEvent(dev, status, byte1, byte2, 0);
> >> //...code left out
> >> }
> >> }
> >> return noErr;
> >> }
> >>
> >> (the code has been edited for clarity)
> >>
> >> The crash happens somewhere inside the MusicDeviceMIDIEvent call,
> >> about 11
> >> calls deep.
> >>
> >> Is there a known issue with DLSMusicDevice and large sound fonts
> >> crashing
> >> when the system is under strain? The crash could be due to a problem
> >> elsewhere in my code of course, but I wanted to check to see if
> >> there's a
> >> known issue.
> >>
> >> Another problem is that the sound font does sound pretty bad (loads of
> >> crackles. glitches etc.) I presume this is due to lack of CPU cycles
> >> and
> >> there's not much I can do other than optimize my app generally. Is
> >> this is
> >> the case?
> >>
> >> Thanks,
> >> Yasir Assam
> >> _______________________________________________
> >> coreaudio-api mailing list | email@hidden
> >> Help/Unsubscribe/Archives:
> >> http://www.lists.apple.com/mailman/listinfo/coreaudio-api
> >> Do not post admin requests to the list. They will be ignored.
> > _______________________________________________
> > coreaudio-api mailing list | email@hidden
> > Help/Unsubscribe/Archives:
> > http://www.lists.apple.com/mailman/listinfo/coreaudio-api
> > Do not post admin requests to the list. They will be ignored.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Crash playing through DLSMusicDevice with large sound fonts
      • From: Chris Reed <email@hidden>
References: 
 >Re: Crash playing through DLSMusicDevice with large sound fonts (From: Chris Reed <email@hidden>)

  • Prev by Date: Re: Revised: Audio Unit Guidelines 2.0
  • Next by Date: Re: Crash playing through DLSMusicDevice with large sound fonts
  • Previous by thread: Re: Crash playing through DLSMusicDevice with large sound fonts
  • Next by thread: Re: Crash playing through DLSMusicDevice with large sound fonts
  • Index(es):
    • Date
    • Thread