Re: only on cocoa?
Re: only on cocoa?
- Subject: Re: only on cocoa?
- From: William Stewart <email@hidden>
- Date: Sun, 12 Aug 2001 20:25:46 -0700
You could also peruse the Java classes for CoreAudio. CoreAudio itself
(though published as a C API) is internally implemented in C++, so the
API is very OO in its flavour. The Java classes probably best express
that re-translation into objects (with garbage collection), and uses
Java interfaces to express the usage of callbacks that the API
publishes. It might help you as a model for structuring your classes if
you want to delve into Obj-C
Bill
On Sunday, August 12, 2001, at 05:07 PM, email@hidden wrote:
Hi, Thanks a lot for the link James. I've been given myself a crash
course/refresher in Obj-C and Cocoa development this weekend, so I've
actually managed to progress a little bit in terms of the point of my
question about Obj-C and the CoreAudio APIs. The thing is that I would
like to write a callback, for instance an AudioDeviceIOProc, in a way
that maintains the object-oriented nature of Obj-C and my classes. It
seems that you can't write it that way. The way James' handled it was by
writing an object oriented class and then writing the AudioDeviceIOProc
method as a C function
OSStatus audioCallback (AudioDeviceID inDevice, const AudioTimeStamp*
inNow, ..., void *defptr) {}
so it can't access any of the object's variables directly but only
through
a struct defined as
typedef struct {
@defs(ClassNameGoesHere);
} classnamegoesheredef;
and passed to the AudioDevice so it passes the struct as the defptr
argument in the class' AudioDeviceIOProc function. So, basically unless
there's some way for me to write an AudioDeviceIOProc as "real" Obj-C
method i.e.
- (OSStatus) audioCallback: (AudioDeviceID) inDevice
inNow: (const AudioTimeStamp*)inNow
inInputData: (const AudioBufferList*)inInputData
etc...
it looks like I have to write struct defs for every object I want to
access in the callback. If anyone knows how to pass an Obj-C instance
method as an AudioDeviceIOProc don't read further and just let me know
(sample code appreciated). I'm fairly certain it can't be done, so
now I have to figure out how to be able to access multiple different
objects (instances) and hopefully make it so I can only modify some
instance variables whereas others I can get the value of the variables
but
cannot change (ie. have accessor methods through this struct I pass in).
I'm really disappointed in the way it seems the interaction with this
API
is going to have to work and restructure my program from being object
oriented to being "kinda' object oriented" and I'll have to relearn all
the arcane ways of advanced C and figure out how to combine that with
object oriented programming as done with Obj-C code. It seems like more
of
a kludge than blending pascal and C as those two had similar, simple
ways
of modelling data and process flow.
Thanks for any advice/flames,
Ben
On Sat, 11 Aug 2001, James McCartney wrote:
on 8/11/01 3:20 AM, email@hidden at email@hidden
wrote:
Obj-C is C and the API is C, so you just make C calls.
For an example see my simple Cocoa demo app :
http://www.audiosynth.com/sinewavedemo.html
--- james mccartney email@hidden
<http://www.audiosynth.com>
SuperCollider - a real time synthesis programming language for the
PowerMac.
<ftp://www.audiosynth.com/pub/updates/SC2.2.10.sea.hqx>
_______________________________________________
coreaudio-api mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/coreaudio-api