[PD] Libpd running in OS X app

Joe White white.joe4 at gmail.com
Mon Jul 8 12:20:53 CEST 2013


Thanks for the link Rich!

I had a look at your code and I could get the tone patch to work with input
disabled, but enabling input caused an error:

* *** ERROR *** -[PdAudioUnit
initAudioUnitWithSampleRate:numberChannels:inputEnabled:][159] status code
=  kAudioUnitErr_InvalidPropertyValue*

I think this is due to the fact that with kAudioUnitSubType_HALOutput you
need to set up two callbacks for input/output processing:

*kAudioOutputUnitProperty_SetInputCallback* for retrieving the input
samples by calling the AudioUnitRender() method, processing the samples and
storing them into a ring buffer.

 *kAudioUnitProperty_SetRenderCallback* for retrieving the samples stored
in the ring buffer to output.


I have a HAL Output Unit working with AUGraph in a controller class. I'll
try and wrap it up this week and share it.

However for this purpose I didn't need audio input so I opted for the
Default Output unit. As you can see in the link from the previous email
this simplifies the code A LOT :) Maybe it'd be useful to have two projects
for output only and input/output. With the former being a very quick way
for people new to libpd to get a project up and running.

Regarding my issue with libpd not processing audio, as Dan pointed
out, it *should
*be working. However, thinking about it more it could be due to how I built
the libpd library. I noticed Rich added the whole source code into his
project so I'll try that and see if it makes any difference. Weird!

Thanks for the help guys,

Joe

On 7 July 2013 03:02, Rich E <reakinator at gmail.com> wrote:

> I started adding support for using PdAudioUnit in a Cocoa / OS X app
> (PdAudioController is too iOS-specific) and checked my progress into the
> cocoa branch here:
>
> https://github.com/libpd/libpd/tree/cocoa
>
> There is a (very basic) working app at:
>
>
> https://github.com/libpd/libpd/tree/cocoa/samples/cocoa_samples/CocoaPdBasic
>
> You can also find some experimentation I did with moving towards an
> AUGraph design but, in the end, I found it much more restrictive than just
> using Audio Units directly.  Apologies for not finding the time to finish
> this, I've been working full-time on a different project for many months
> now... but hopefully once that is done I will finish off those samples,
> unless someone else already has.
>
> In essence, there were only a few things that needed to be modified. Off
> the top of my head, they were:
>
> - switch the audio unit to kAudioUnitSubType_HALOutput
> - enable an input audio device (required on OS X, not on iOS)
> - fix some Obj-C syntax issues that are different on OS X (property
> synthesis generation I believe)
>
> By the way, you can use the C++ wrapper quite readily with any other
> existing audio framework that provides OS X support - I use it in cinder
> apps and of course Dan provides ofxPd.  I know others who have used
> portaudio or FMOD directly.
>
> cheers,
> Rich
>
>
> On Sat, Jul 6, 2013 at 9:04 AM, Dan Wilcox <danomatika at gmail.com> wrote:
>
>> Sorry. I assumed you were using the existing Obj-C PdAudioUnit and
>> PdAudioController classes included with libpd which were written mainly for
>> iOS. We should get around to tweaking it so it works on OSX. Did you try it?
>>
>> In skimming your code, it looks like you're doing everything the
>> PAudioUnit does, so I don't see any obvious problems.
>>
>>
>> On Jul 6, 2013, at 8:52 AM, Joe White <white.joe4 at gmail.com> wrote:
>>
>> Sorry that previous code had some test stuff in it, here's a slightly
>> cleaner version (ARC'd)
>>
>> http://pastebin.com/index/1bR2Ftqn
>>
>> On 6 July 2013 13:47, Joe White <white.joe4 at gmail.com> wrote:
>>
>>> How do you mean the CoreAudio backend? I would have thought I should
>>> just be able to call the process function in my render callback. Did you
>>> check out the code I posted? I happy to provide that as an AudioController
>>> for libpd on OSX. Messages and print objects work correctly but libpd is
>>> not processing any audio.
>>>
>>> http://pastebin.com/1bR2Ftqn
>>>
>>> Cheers,
>>> Joe
>>>
>>>
>>> On 5 July 2013 23:33, Dan Wilcox <danomatika at gmail.com> wrote:
>>>
>>>> As far as I know, the OSX port isn't finished and the CoreAudio backend
>>>> isn't hooked up. Anyone wanna help out there or sponsor us? :D
>>>>
>>>> On Jul 5, 2013, at 7:56 AM, pd-list-request at iem.at wrote:
>>>>
>>>> *From: *Joe White <white.joe4 at gmail.com>
>>>>  *Subject: **[PD] Libpd running in OS X app*
>>>> *Date: *July 5, 2013 7:34:47 AM EDT
>>>> *To: *pd-list <pd-list at iem.at>
>>>>
>>>>
>>>> Hi guys,
>>>>
>>>> Does anyone have any experience running libpd in an OS X app, using
>>>> CoreAudio.
>>>>
>>>> I'm able to run a patch and receive print statements but I'm not
>>>> getting any audio output and DSP doesn't seem to be processing. I created a
>>>> quick test tone in code to see if it was my audio unit but that works. My
>>>> main problem it seems is that after calling
>>>>
>>>>   [PdBase processFloatWithInputBuffer:leftBuffer outputBuffer
>>>> :leftBuffer ticks:ticks];
>>>>
>>>> ...the buffer is still empty. Anyone have any ideas?
>>>>
>>>> I'm calling [PdBase computeAudio:] just before I start the AudioUnit.
>>>> Here's the whole controller class if that helps:
>>>> http://pastebin.com/eYf1Facp
>>>>
>>>> Any help would be much appreciated!
>>>>
>>>> Many thanks,
>>>>
>>>> Joe
>>>>
>>>>
>>>>  --------
>>>> Dan Wilcox
>>>> @danomatika
>>>> danomatika.com
>>>> robotcowboy.com
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Follow me on Twitter @diplojocus
>>>
>>
>>
>>
>> --
>> Follow me on Twitter @diplojocus
>>
>>
>>  --------
>> Dan Wilcox
>> @danomatika
>> danomatika.com
>> robotcowboy.com
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Pd-list at iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> http://lists.puredata.info/listinfo/pd-list
>>
>>
>


-- 
Follow me on Twitter @diplojocus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20130708/e297b431/attachment.htm>


More information about the Pd-list mailing list