The NSSound class provides a simple interface for loading and playing audio files. This class supports the same audio encodings and file formats that are supported by Core Audio and QuickTime.
Questions tagged [nssound]
39 questions
11
votes
1 answer
Convert NSSound to AVAudioPlayer
I have some NSSound objects that I'd like to convert to AVAudioPlayer instances. I have file paths (NSURLs) associated with the NSSound objects, but the original file may not exist. Here is what I have so far:
class SoundObj: NSObject {
var…

Matt
- 2,576
- 6
- 34
- 52
6
votes
1 answer
Playing NSSound in NSObject (Mac App with Objective-C)
I'm making a game that needs to play music. To make my code more manageable, I wanted to make an NSObject that takes care of the sounds (like fading, playing sounds in a playlist, etc). I have this code:
NSSound *music = [[NSSound alloc]…

Developer
- 406
- 1
- 4
- 18
6
votes
2 answers
How can I add sound to a button in iOS?
I would like to make a sound play when a button is pressed. Also, there is more than one sound. I am using Xcode 4.4.1 and Storyboard.
In the .h file
{
IBOutlet UIButton *playSound;
}

user
- 99
- 1
- 1
- 5
5
votes
2 answers
Is there any WAV sound playback on Mac from Delphi XE2?
Are there any tutorials or examples on how to play WAV files on Mac from application built by Delphi XE2 FireMonkey?
I'm asking because this code does not work:
var
//fWaves head and data is initialized and plays properly on Win through OpenAL
…

Kromster
- 7,181
- 7
- 63
- 111
5
votes
3 answers
How to fade an NSSound object
I've written a cheap & cheerful sound board in for my Mac, and I play the various sounds with NSSound like this:
-(void)play:(NSSound *)soundEffect:(BOOL)stopIfPlaying {
BOOL wasPlaying = FALSE;
if([nowPlaying isPlaying]) {
…

Stuart Grimshaw
- 1,541
- 1
- 18
- 41
4
votes
1 answer
Play NSSound more times, simultaneously
I need to insert a code, in function, that when called play a sound.
The problem is that the function is called faster than sound duration and so, the sound is played less times than function calls.
function keyDownSound(){
NSSound(named:…

Alessandro
- 199
- 2
- 16
4
votes
1 answer
Sound picker / List of system sounds on macOS
Okay. I was looking for a neat way to list system sounds that are played with [NSSound soundNamed: ] - and to me it seemed that API does not have list of available sounds.
I also searched this with google and found some pretty old and partially…

jake1981
- 303
- 3
- 11
3
votes
2 answers
What's the SIMPLEST way to play a sound clip in an iPhone app?
I want to be able to play a sound clip in an iPhone OS app. I've seen info on both NSSound as well as AVFoundation as being means for getting sound clips played on an iPhone OS device, but I'm still not clear on the subject and could use some help.…

RexOnRoids
- 14,002
- 33
- 96
- 136
3
votes
3 answers
NSSound undeclared on iPhone?
sound = [[NSSound alloc] initWithContentsOfFile:@"staticbeam09.wav" byReference:YES];
Code referenced from Apple docs. Getting an error when I put this in viewDidLoad. If I put
NSSound *sound;
in the header file, I get the specifier-qualifier…

quantumpotato
- 9,637
- 14
- 70
- 146
3
votes
0 answers
Play sound in arbitrary channel
(OSX/Cocoa)
I need to be able to take any sound (or sounds) from a collection of sound files and play it (or them) through an arbitrary sound output channel, preferably with per-sound level control and more-or-less automatic channel mixing. (meaning…

pawneebill
- 171
- 6
2
votes
1 answer
How to make a NSSound loop
I'm attempting to make a simple application on XCode (in Swift) that plays an audio file, then keeps looping infinitely. According to Apple's website, I need to add var loops: Bool { get set } to my code; but I'm not sure how to combine that with my…

htmlcat
- 336
- 3
- 10
1
vote
1 answer
getting an exception 4.3 on an NSSound object
I load a sound like so:
sound = [[NSSound alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"alert" ofType:@"mp3"] byReference:NO];
Also I have "all exceptions" break point turned on in xCode. The above line throws an exception…

PrimeSeventyThree
- 940
- 2
- 9
- 24
1
vote
1 answer
Localized name for default sounds in /System/Library/Sounds
In the Mail settings one can choose one of the default sounds located at /System/Library/Sounds. Playing them is easy, e.g. with NSSound(named: "Purr")?.play(), but how can I show a localized name for those sounds as Mail does? I couldn't find any…

Nickkk
- 2,261
- 1
- 25
- 34
1
vote
1 answer
NSSound crashing when trying to load a system sound
Occasionally my Cocoa app crashes while trying to load a system sound. I've not been able to reproduce this myself, but a few users have sent me crash reports.
The stack trace is always the same (see below). The app opens a modal dialog, the user…

Mark
- 6,647
- 1
- 45
- 88
1
vote
1 answer
Cannot find type 'NSSound' in scope
In this tutorial: https://swiftui-lab.com/swiftui-animations-part4/
I'm trying to run the metronome, about 1/2 way down the page. It's a simple call to NSSound and I get an error cannot find the type. I change that type to "Any" and then it…

KarlJay
- 79
- 1
- 9