• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Extracting and Saving a 'SND ' Resource;;;
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extracting and Saving a 'SND ' Resource;;;


  • Subject: Re: Extracting and Saving a 'SND ' Resource;;;
  • From: Matt Budd (Madentec) <email@hidden>
  • Date: Tue, 15 Feb 2005 09:44:01 -0700

Just FYI, I've solved this problem by using the QuickTime method. You simply create a QT movie, and then use the PasteHandleIntoMovie() and SetMovieSelection() functions to paste the 'snd ' resource into the movie. You can then convert the QT movie into an aiff file pretty easily using the ConvertMovieToFile() function.

 - Matt


On Feb 2, 2005, at 4:40 PM, Matt Budd (Madentec) wrote:

Hi Jason,

I thought the same initially, but tried code similar to yours. To make sure I wasn't crazy, I copied your code, and tried it and had the same result. When the file is saved using this method, it is not a valid .snd file. I open it using "SoundHack" and that program reports that it is a "headerless sound file" (which sort of makes sense as to why they look different in a hex-editor).

Is there a way I can retrieve this .snd header from the 'snd ' resource and prepend it to the output file from your code below? It seems that without this, the file created by that code is not valid.

 - Matt

P.S. - I've also CC'd the quicktime guys, on this since to generate this header I might have to do some crazy QT stuff?


On Feb 2, 2005, at 3:20 PM, Jason Harris wrote:

As far as I can tell from the docs, the 'SND ' resource should be complete. You can get your handle into an NSData and then save it off to disk doing the following:

Handle mySoundHandle;
// get the sound from the resource
SInt8 state = HGetState( mySoundHandle );
HLock( mySoundHandle );
NSData *data = [NSData dataWithBytes: *mySoundHandle length: GetHandleSize(mySoundHandle)];
HSetState( mySoundHandle, state );


[data writeToFile: fileSystemPath atomically: NO];

Jason


On Feb 2, 2005, at 12:00 PM, Matt Budd (Madentec) wrote:

I'm trying to extract and save a 'SND ' resource from an old OS 9 program that I have. I use ResEdit in Classic-mode and I know the ID of the SND resource (it's 1024). I have the file open, and can use the GetResource('snd ', 1024) API call which returns to me a non-NULL "Handle" data type.

Basically I want to (in code) read from this Handle to a SND resource, and save a .snd or .aiff file on the hard drive. I was thinking of just writing the contents of the Handle to a file, but that didn't seem like it was going to work (if I hex-edit the contents of an existing .snd file, it seems to have a header chunk that the SND resource doesn't). I was also looking a bit on the net and it seems like I can load a QuickTime movie with the 'SND ' resource, and then save that move's soundtrack to disk.

The quicktime solution seems feasible, but also seems like a lot of overhead to just write to disk that which I already have in memory. Do you guys have any guidance or direction for me?

 - Matt

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • IB question
      • From: James Hannigan <email@hidden>
References: 
 >Extracting and Saving a 'SND ' Resource; (From: Matt Budd (Madentec) <email@hidden>)
 >Re: Extracting and Saving a 'SND ' Resource; (From: Jason Harris <email@hidden>)
 >Re: Extracting and Saving a 'SND ' Resource;;; (From: Matt Budd (Madentec) <email@hidden>)

  • Prev by Date: Still no Moving Files/Folders to Trash call?
  • Next by Date: Re: Still no Moving Files/Folders to Trash call?
  • Previous by thread: Re: Extracting and Saving a 'SND ' Resource;;;
  • Next by thread: IB question
  • Index(es):
    • Date
    • Thread