PortAudio Port Help Request

Brad Fuller brad at sonaural.com
Thu Nov 3 01:32:35 UTC 2005


John M McIntosh wrote:

> I'll note you can choose to either make:
>
> A lightweight plugin that interfaces to a platform-agnostic api that  
> requires you to use lots of platform specific C code.
>
> A heavyweight class(es) that manages data and passes data only to a  
> plugin which makes the DLL API call, no pre/post C code wrapping api  
> call.
> or a plugin that abuses self cCode: inSmalltalk: and makes the api  
> calls required and has no external C code, except for say a DLL  
> library of some sort.

Thanks for your input, John.
Don't you think the former (lightweight) would be more beneficial (in 
the long run) for cross platform support? Then again, any update to 
PortAudio might mean more C programming in the primitive? (oopss.. you 
agree.. I just re-read below!)

What do you suggest?

>
> Or of course use FFI.

Don't you think FFI would not be a good choice for my goal to be easily 
cross platform? I don't know, I don't have any real-world experience 
with primitives nor FFI except for reading the doc on the swiki

>
> In some respects exposing the RAW DLL API in a plugin then having a  
> heavyweight class drive it is best because any changes to logic can  
> mostly be done in smalltalk, otherwise
> with a platform agnostic API you get to post and mange change via  
> external C code and publish plugins forever...
>
> So for example:
>
> primitiveMPEG3AudioSamples: fileHandle stream: aNumber
>     | file result |
>
>     "long mpeg3_audio_samples(mpeg3_t *file, int stream)"
>     self var: #file declareC: 'mpeg3_t * file'.
>     self primitive: 'primitiveMPEG3AudioSamples'
>         parameters: #(Oop SmallInteger).
>
>     file := self mpeg3tValueOf: fileHandle.
>     file = nil ifTrue: [^0].
>     aNumber < 0 ifTrue: [interpreterProxy success: false. ^nil].
>     aNumber >= (self cCode: 'mpeg3_total_astreams(file)') ifTrue: [
>         interpreterProxy success: false. ^0.
>     ].
>
>     self cCode: 'result = mpeg3_audio_samples(file,aNumber)'.
>     ^result asOop: Float
>
>
> I could have made the check for file nil, and the check for stream  
> part of the smalltalk code that interfaces to the plugin so that I  
> would only have
> primitiveMPEG3AudioSamples: fileHandle stream: aNumber
>     | result |
>
>     "long mpeg3_audio_samples(mpeg3_t *file, int stream)"
>     self var: #file declareC: 'mpeg3_t * file'.
>     self primitive: 'primitiveMPEG3AudioSamples'
>         parameters: #(Oop SmallInteger).
>     self cCode: 'result = mpeg3_audio_samples(file,aNumber)'.
>     ^result asOop: Float
>
> Note we return the samples as a Float to avoid the issue with small  
> versus large integers. I guess today we could return a 32bit Integer,  
> but I believe those methods was added later when we were working on  
> the large file indexing support.


-- 
Brad Fuller
(408) 799-6124
** Sonaural Audio Studios **
(408) 799-6123  West San Jose
(408) 799-6124  Cambrian
________________________________
Hear us online: www.Sonaural.com
See me on O'Reilly: http://www.oreillynet.com/pub/au/2184




More information about the Squeak-dev mailing list