Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I thought I would add some dice rolling sounds to my dice application but everything I find online is directed towards iphone. Is it the same process for a standard OS X app?

Any doc's or where to look for this would be much appreciated.

-Lars
 

PatrickCocoa

macrumors 6502a
Dec 2, 2008
751
149
NSSound

Try NSSound. I've written a Mac bouncing ball app (not on the Mac App Store) that picks a song to play in the background. Each song is just an .aif file that I put in the Xcode project.

[NSSound soundNamed:mad:"MySong.aif"];

There's more that needs to get done to get this to play.

If you're looking for a die roll sound the above might work (think of the die roll sound as a very short sound). But someone else may have a better way.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Thanks, I will read up on NSSound tonight and take another step in learning.

-Lars
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Cool, I got the sound to play when the dice roll button is clicked. But I am getting this weird result. I have a NSSlider that sets the minimum number that can be rolled, ie, 1 to 100 or 34 to 100, as an example. But that slider is also acting like a volume control. The higher the value the louder the roll?

In the @interface I just have NSSound * sound; and Method deceleration.

Code:
@implementation 

-(void)playAudio{
    sound = [[NSSound alloc] initWithContentsOfFile: @"/Users/larspro/diceRollSound.aif" byReference:YES];
[sound play];
}

How could that slider even be connected to the audio?

-Lars
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
NEVER MIND! I found out the problem. I guess my degree in sound engineering paid off tonight. I placed the [self playAudio]; in the loop section with the dice. So every time the dice had to re roll to get above that number ir played the sound again, each iteration would amplifying the sound. Had nothing to do with the slider.

-Lars
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.