Re: Objective C and C++
Re: Objective C and C++
- Subject: Re: Objective C and C++
- From: Brian Willoughby <email@hidden>
- Date: Sun, 21 Dec 2008 23:41:50 -0800
I don't intend to offend with the following comment, but you really
do need a solid background and understanding of C, C++, and Objective
C to do what you want. Both C++ and ObjC are supersets of C, and
they can each make full use of any Standard C construct. Just
because you see a program written in C++, that does not mean that
every line of code depends upon C++. Likewise with ObjC. If you
look specifically at the CoreMIDI API calls, you will see that they
are not necessarily using any features that are specific to C++, but
are merely using the Standard C subset of C++. ObjC can use the
exact same Standard C. Data structures and local variables might be C
++, and you will need to understand both C++ and ObjC to translate
them, but hopefully your code will have its own design.
There is plenty of information in the CoreMIDI and CoreAudio examples
for you to use. However, if you do not fully understand the
differences between Standard C and C++, then you will not get the
full benefit of the C++ example code. There's not anything Apple or
any of us can do about that, except perhaps to point you to
documentation on these ubiquitous languages. I'm not saying this is
necessarily a shortcoming on your part, because most classes today do
not cover Standard C by itself. I have also taught "C" to new
programmers, and many are in too much of a hurry to study the basis
of C++ by examining Standard C in isolation. The whole situation
leads to much confusion, and Apple is not responsible for this.
But Apple can still take your advice to heart. More Standard C
examples would be helpful, since they could be incorporated into C++
or ObjC without necessitating so much in-depth knowledge of the
"other" language. Also, if Apple were to provide more ObjC examples
for the C API like CoreAudio and CoreMIDI, then new programmers who
are learning C and ObjC for the first time would not have the
additional burden of learning C++ and how to break out the Standard C
lines from the rest. There is a big market for new programmers
learning Cocoa and ObjC, so the focus on C++ examples can be a
serious hurdle.
Brian Willoughby
Sound Consulting
On Dec 21, 2008, at 22:16, Brian Hughes wrote:
I really appreciate your responses. The only reason why I thought I
needed to use C++ was because all the apple examples use C++. See the
examples in SimplesSDK, and MIDI such as:
PlaySoftMidi (main.cpp)
PlaySequence (main.cpp)
PlayFile (main.cpp)
DefaultOutputUnit (main.cpp, RenderSin.cpp)
ConvertFile (UseAC-AF.cpp, UseExtAF.cpp, utils.cpp
SampleTools (Echo.cpp)
HalLab is littered with C++ files as is AudioFileTools,
AudioUnitHosting etc.
My situation is quite simple. I want an action method in my
appController (which is written in ObjectiveC) to send midi messages
to either a virtual synthesizer or an external synthesizer. What I
learned from PlaySoftMidi was how to successfully play apple's
virtual synthesizer (in C++). And now I can get it to do just about
anything I want by editing the code in PlaySoftMidi but I cannot seem
to get anything to happen from inside my Cocoa app.
So let's say I abandon trying to do it in C++. I would happily do
that. My head is bloodied enough from banging on the C++ wall. But
there aren't any examples that use C. So, how would I do that?
Brian Hughes
_______________________________________________
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