Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for December, 2011


Hi !
  I’d like to know the ImageDescriptionHandle of a track.
How can I get it ?

posted by admin in Uncategorized and have Comments (2)

Creating Custom Instruments

Hello everyone,

I am struggling with a pretty obscure area, the QT tune player and I’ve
been banging my head trying to create a custom Musical Instrument from a
System 7 sound.

I’ve translated the QTMusic.c example from the developer source code
pages and it works ok, but it doesn’t do exactly what I want.

I want to use the new Atomic Instrument from the tune player, and NOT
from the Note Allocator.

The example builds the atomic instrument and then uses:
NANewNoteChannelFromATomicInstrument to instanciate a new channel which
is then passed to NAPlayNote to play some notes.

This is fine and dandy, but how can I use this instrument to force the
tune player to recognise it?

The built atomic instrument is a handle, built using QTInsertAtom.
Saving this handle as a resource and looking at it using resorcerer, it
appears suspiciously close to the resources of type ‘ssai’ included
inside the QuickTime Musical Instruments extension, save from some small
differences in the header.

However, I’ve tried all available avenues yesterday, including:

Pasting the saved resource as a resource of type ‘ssai’ and id 17000 to
the QuickTime Musical Instruments extension.

Pasting the resource inside the QUickTime extension (which contains one
single ‘ssai’ resource, probably the Rhodes piano),

Tried calling the following sequence from within my program:

err := QTLockContainer(customInstrument);
if err = noErr then
err := NANewNoteChannelFromAtomicInstrument(na, customInstrument^, 0,
if err = noErr then
err := QTUnlockContainer(customInstrument);
if (err = noErr) and (customChannel <> nil) then
err := TuneSetNoteChannels(tp, 1, customChannel, nil, 0);

(The above doesn’t return any errors, but doesn’t do anything. My
channel still plays using the piano instrument)

Tried every other imaginable thing I could come up with, but I could not
make the new instrument show up in the Instrument Picker

Since the Musical Instruments _appear_ to be the ‘ssai’ resources
included in the QuickTime Musical Instruments extension, there MUST be a
way to place this new resource SOMEWHERE so as to have the instrument
picker recognize the new custom instrument.

Does anyone have some clues on how this might be done?

I’ve been banging my head for over 20 hours with this, so any help from
anyone who knows is greatly appreciated. The QTMA.pdf documentation is
pretty sparse about this. It mentions that it CAN be done, but doesn’t
tell how, exactly.

Thanks much in advance.

"You cannot go against Nature, because going
against Nature is part of Nature too".

posted by admin in Uncategorized and have No Comments

MoreFilesX – FSGetDirectoryItems


Has anyone tried using FSGetDirectoryItems? Its second parameter is an
FSRef*** which is supposed to be a pointer to a handle of FSRefs. I’ve

FSRefPtr *theRef = new FSRefPtr;

and just

FSRefPtr *theRef;

along with a few variations, sometimes allocating a given size [1024] or
whatever, but nothing seems to work. The method comment indicates that the
caller is responsible for disposing of refsHandle but I think I have to
allocate something beforehand….

I stepped into the method and things seem to be working ok, except that the
second element in the FSRef** array always ends up being 0xFFFFFFFF so I am
pretty sure I’m just not allocating the memory correctly for
FSGetCatalogInfoBulk to eventually do its work.

Any pointers would be greatly appreciated.


posted by admin in Uncategorized and have Comments (6)

Re: erase antialiased text (TextMode)?

In Article noEmail-BBC0E1.17341617112…, Jim Meiss

> With non antialiased text if you do TextMode(scrOr) DrawString("\pSome stuff")
> twice, then it first draws then erases the text…leaving stuff that is not
> under the letters alone.

> If you do this when text is antialiased (at least under OS 9 with Carbon 1.6)
> then there are artifacts left behind (these are grey pixels when the ForeColor
> is black and the background is white).

Did you mean srcXor? Otherwise you’ll have to set the fore color to match
background in order the second draw to erase. But then, you can erase by
painting rect over text. Or if the text is over some background, you can
save bits using CopyBits, then draw text and then CopyBits again to
"erase". Or just redraw background, whatever it is. Pick whatever is more

Mike Kluev.

PS. Remove "-DELETE-." part of my e-mail address to reply.

posted by admin in Uncategorized and have Comment (1)

program quits due to signal 10(SIGBUS) on OSX.2

I am using Project Buildet, part of Developer Tools provided by Apple,
to create a cocoa application.  I am using OS 10.2.1.
The program compiles, but when running it quits in the first 3 seconds
with the message of:
"…has exited due to signal 10 (SIGBUS)."
Please let me know what I can do to prevent my application to reach
that message.
Thank you.

posted by admin in Uncategorized and have Comments (3)

buttons on a background pattern in a rectangle


I’m doing my first port to OS X.
I have windows with background patterns. Buttons
are now drawn in a rectangle and the whole rect
erases the background pattern.

How can I get just the button to draw without
messing up the background pattern?


john elemans

posted by admin in Uncategorized and have No Comments

Carbonization Keyboard/Mouse help

The game I’m carbonizing has the following function…

boolean test_control_definition(
        struct control_definition *control)
  boolean asserted= FALSE;

  switch (control->device)
    case _input_device_none:
    case _input_device_joystick:

    case _input_device_keyboard:
        int bit_index= macintosh_keymap_bit_offsets[control->code];

        asserted= ((volatile byte


    case _input_device_mouse:
      asserted= ((control->code==_mouse_button_left) ? !*((volatile
byte *)0×172) : FALSE);


  return asserted;


It looks to me like its directly referencing interrupts – works under
Classic but crashes, unsurprisingly, on OS X.

My research so far has found no answers as to how to rewrite this for
OS X – any help or suggestions would be greatly appreciated.


posted by admin in Uncategorized and have Comments (3)

Re: getting PIDs and using NSTask

On Wed, 20 Nov 2002, Mark Haase <n…@spam.please> wrote:
> 1) what is the best way to get the PID for any arbitrary app running on
> the system??

Any process, or only GUI applications?  If the latter, then
[[NSWorkspace sharedWorkspace] launchedApplications] will give you the
PID (and name, and other information) of all the user-visible (i.e.,
in the Dock) applications on the system.

> 2) is there any way to block on an NSTask?? i want to have a function
> called getDockPID which calls the two tasks, pipes them together, and
> reads the output to cull the right PID…however if NSTask runs
> asynchronously then this isn’t possible as far as i can tell..

[task waitUntilExit];

Alexei Kosut <ako…> <>

posted by admin in Uncategorized and have Comment (1)

Audio CD Info unique key

Does anybody know how to calculate the 16-byte key that identifies a
CD for lookining up track names in the CD Info.cidb file. For each CD,
there are 24 bytes in the indx section of the CD Info.cidb file. The
first 16 is the unique key, then follows 4 bytes which is the offset
in the cidb-file for the album info, then follows 4 bytes that is the
number of tracks and lead out MSF.

I can give you some examples (TOC information and corresponding key).


posted by admin in Uncategorized and have Comment (1)

Accessing arrays in other classes

I have a "Viewer" class and a "Polyhedron" class. The Polyhedron class contains
among other things several NSMUtableArrays containing vertexes, normal vectors,
and so on. The Viewer needs to access these arrays from the Polyhedron objects
in order to display them.

I’m not sure which is the best way to do this; should I use an accessor method
to copy the entire array into a similar array in the Viewer class and use that?
Or should I use an accessor method each and every time I need a number in the
Polyhedron object array to store the number I need in a variable and then use

Is there a third, better way to do this?

C Lund, Oslo

posted by admin in Uncategorized and have Comments (4)