THSound

Here is where the magnanimous folks that create externals post them (.zip archives only please).

THSound

Postby sctell » Mon Jun 06, 2011 11:47 am

Hi,

A quick external based upon the Cocoa NSSound API.

The functions available are:

put THSound("soundTypes") into cd fld 1 -- the sound types that can be played
get THSound("loadSoundAtPath",tFilePath)
get THSound("play")
get THSound("pause")
get THSound("resume")
get THSound("stop")
get THSound("setLoops",true) -- or false
get THSound("setVolume",tVol)

I have compared it briefly against the sound routines in SC and I have noticed that in SC 4.6.3 (not sure about 4.7) SC does not seem to play AAC format sounds whereas this external does.

I believe AAC is the format Apple uses in iTunes.

Here is a short paragraph from Apple about NSSound that you may find useful:

Depending on the type of the audio data, this class may use either Core Audio or QuickTime to handle the actual playback. (Typically, it uses Core Audio to play files in the AIFF, WAVE, NeXT, SD2, AU, and MP3 formats and may use it for other formats in the future as well.) Playback occurs asynchronously so that your application can continue doing work.


THSoundTest.zip
Last edited by sctell on Fri Jul 22, 2011 10:55 pm, edited 1 time in total.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THSound

Postby mrBean » Wed Jun 15, 2011 2:40 pm

This mite be a bit much to ask, but since you are working with audio and core graphics, I was wondering if there is a way to use CG to generate a sound wave. The reason I ask is because I've created a little project to help me sink text based subtitles to a mp4 video file.
User avatar
mrBean
 
Posts: 89
Joined: Sat Jan 30, 2010 8:03 am
Location: New York

Re: THSound

Postby sctell » Thu Jun 16, 2011 4:21 am

Hi,

I am a little confused.

Do you want to produce a sound wave (tone) or a graphic of a sound wave or both?

-----------------
If a tone you will need to work really hard to understand Core Audio and perhaps QTKit.

I have tried looking into both and have to be honest found it to heavy going.

The documentation is **** poor for beginners and it appears, having scouted around the internet, that those who have mastered or even understand a little are not prepared to share their knowledge.

Apple's documentation compared to the Cocoa classes/examples I have found to hard to bother. It's as if those that created Core Audio don't want to share/educate.

Core Graphics, although not as straight forward as Cocoa (in my opinion) is easy in comparison to Core Audio.
----------------

If a graphic I would recommend you look at NSBezierPath which is built on top of Core Graphics and is easier to follow for the production of graphs (wave form).

----------------

Does this help?
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THSound

Postby mrBean » Thu Jun 16, 2011 11:47 am

Thanks for all your help, it seams like you put a lot of work into answer my question.

Sorry for not being clear, writing is with out a doubt not my specialty. What I'm looking to do is produce a graphical representation of a sound wave based off an actual audio found in a movie file. Just like they would have in an audio program like ProTools.

I'm unclear on one point; Dose Core Graphic on its own have the ability to generate a waveform based of real audio, or do I have to use Core Audio and Core Graphic in conjunction with one another?
User avatar
mrBean
 
Posts: 89
Joined: Sat Jan 30, 2010 8:03 am
Location: New York

Re: THSound

Postby sctell » Fri Jun 17, 2011 9:31 am

Hi,

You will have to analyse the sound in CoreAudio

Then produce the WaveForm with CoreGraphics.

As I said the information on the internet/Apple is not good for me but your mileage may vary.

Before you start coding have a look through Apple's docs on CoreAudio and if you can get your head around it then give it a go because I believe CoreGraphics is easier to follow than CoreAudio and certainly the docs/examples are better.

I did find this little example on the internet but it is for ios.

I downloaded it and compiled it in Xcode 4 and it runs in the simulator.

Although NOT the same, ios seems fairly similar to OSX, so you may be able to see whats involved from studying it.

The link is:
http://www.mat.ucsb.edu/594CR/?p=57
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THSound

Postby mrBean » Sat Jun 18, 2011 5:39 am

I hadn't had a chance to check everything out just yet, but I wanted to thank you for all your help.
User avatar
mrBean
 
Posts: 89
Joined: Sat Jan 30, 2010 8:03 am
Location: New York

Re: THSound

Postby witness » Sun Jun 26, 2011 12:09 am

mrBean wrote:What I'm looking to do is produce a graphical representation of a sound wave based off an actual audio found in a movie file. Just like they would have in an audio program like ProTools.

I'm unclear on one point; Dose Core Graphic on its own have the ability to generate a waveform based of real audio, or do I have to use Core Audio and Core Graphic in conjunction with one another?


This blog post by Chris Liscio (author of Capo, an app with one of the most beautiful waveforms on the Mac right now, and one of this year's Apple Design Award winners) might help you learn the general principle: http://supermegaultragroovy.com/blog/20 ... waveforms/

Inspired by that, I wrote my own NSView here: http://github.com/uliwitness/UKSoundWaveformView

I'm doing the drawing in a more low-level way than he did it for more speed, but my guess is you can get away with doing what he does).
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are Everywhere..."
http://www.zathras.de
User avatar
witness
 
Posts: 57
Joined: Thu Jul 17, 2008 2:24 pm

Re: THSound

Postby mrBean » Mon Jun 27, 2011 7:04 pm

Thanks for your help. I haven't had a chance to check everything out yet, but from what I've seen, I'm feeling a little bit more confident about my chances of pulling this off.
User avatar
mrBean
 
Posts: 89
Joined: Sat Jan 30, 2010 8:03 am
Location: New York


Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest

cron