Discussion Forums  >  Audio, Video, Playing, Recording

Replies: 15    Views: 163

Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
06/16/13 06:16 AM (10 years ago)

Sound effects playing in quiz

I started a topic sort of similar to this, but after some searching found a response from David that seemed to solve the issue - almost. Here's what I'm looking to do, which is summed up by David: There's a trick to using your own sound effects. We didn't do a very good job of documenting this, or anything for that matter. It's a three step process to use your own sounds. a) Enter the file name in the control panel (got this) b) Add it to the Xcode project (got this - I put it in she sounds folder and/or images, because I heard it didn't matter WHERE it was stored as long as it was stored, but testing it this way didn't make any difference) c) Tell the application to load this sound (prepare it to play) when the app launches. You did not do this. To do this: a) In BT_Config > [yourAppName]_appDelegate.m file, find the loadSoundEffects method on line 854. You'll see where all the sound effects in the project are added to an array. Add your's to this list. Recompile. That should do it. (I did this, but i'm wondering if I did this right, and if there is anything more I need to do to use a different "right answer" sound in the quiz. If anyone else has successfully gotten a quiz sound to work, please help me.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/16/13 07:53 AM (10 years ago)
Well, In my project, the actual loading of the sound effects is on line 1127 of my xxx_appDelegate.m file, so if you're literally doing this on line 854, you're in the wrong place. It was the right place once, but when all the code was updated for iOS 6, some things got added, some things got deleted, therefore some things had a 'line shift' so to speak... In any event, whichever line it ends up on, it should look sort of like this: ++++++++++++++++++++++++++++++++++ //fill an array of sound effect file names... self.soundEffectNames = [[NSMutableArray alloc] init]; /* [self.soundEffectNames addObject:@"basso.mp3"]; [self.soundEffectNames addObject:@"blow.mp3"]; */ //setup audio session for sound effects... [[AVAudioSession sharedInstance] setCategory.... blah blah blah.... ++++++++++++++++++++++++++++++++++ Just uncomment the existing sound effects, and copy/paste a duplicate line, replacing the values with the ones you want. [self.soundEffectNames addObject:@"myquiznoise.mp3"]; Providing the sounds are added correctly to the project, and called by name in the control panel (and subsequently your BT_config.txt) then you 'should' be good... Cheers! -- Smug
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
06/16/13 08:00 AM (10 years ago)
Thanks a million smug!! I am ALMOST there thanks to you (and David)!! I did find the section you put, and that's where I had changed it, but I don't think I'm uncommenting the existing sound effects. If my file was called "myquiznoise.mp3", how would this section need to look? And is this all I need to change? This is SO easy!! :) Is all I need to do like this??? ++++++++++++++++++++++++++++++++++ //fill an array of sound effect file names... self.soundEffectNames = [[NSMutableArray alloc] init]; /* [self.soundEffectNames addObject:@"basso.mp3"]; [self.soundEffectNames addObject:@"blow.mp3"]; [self.soundEffectNames addObject:@"myquiznoise.mp3"]; */ //setup audio session for sound effects... [[AVAudioSession sharedInstance] setCategory.... blah blah blah.... ++++++++++++++++++++++++++++++++++ Or how should this whole section look? Do I remove something more? Off topic, but when people talk about going to line 876 in XCode, how do you know the exact line number? I always just do the "Find" function to find the section of code. Thanks a million!!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/16/13 08:05 AM (10 years ago)
Make sure your instruction is outside the commented section... //fill an array of sound effect file names... self.soundEffectNames = [[NSMutableArray alloc] init]; [self.soundEffectNames addObject:@"myquiznoise.mp3"]; /* This is a comment... Inside a comment, no one can hear you scream... [self.soundEffectNames addObject:@"basso.mp3"]; [self.soundEffectNames addObject:@"blow.mp3"]; */ //setup audio session for sound effects... [[AVAudioSession sharedInstance] setCategory.... blah blah blah.... Cheers! -- Smug Edit: To clarify just a little bit... comments are made in one of two ways: // this will comment out one line. // this kind of comment works with php and 'C' (ObjC, Java, etc...) /* This will comment out as many lines of text as between those two little thingys... I'm sure they must have a real name. */ <!-- This is an HTML Comment --> The system will ignore anything commented out. Including the instructions for 'Basso.mp3' and 'blow.mp3'. But it will add the 'myquiznoise.mp3' file, which is not commented out.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/16/13 08:15 AM (10 years ago)
For me it's usually faster to search for a particular term, depending on what I'm trying to do. In this instance, since I already knew it was in the BT_appDelegate.m file, I just selected the 'loadSoundEffect' method from the menu at the top of the file inspector window. It took me right to the spot. But that's usually not the case... Unless I'm working on my own plugin, I do a search, lol! Cheers! -- Smug
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
06/09/15 01:18 PM (8 years ago)
Hi guys, Picking up an old thread, just in case you are still working with sounds :) In the new download projects the relevant code is not in AppDelegate.m file anymore, it is now in BT_loadConfigDataViewController.m Starting line 413 //fill an array of sound effect file names... [appDelegate setSoundEffectNames:[[NSMutableArray alloc] init]]; [appDelegate.soundEffectNames addObject:@"bt_funk.mp3"]; [appDelegate.soundEffectNames addObject:@"bt_glass.mp3"]; The issue I am coming across is that changing bt_funk.mp3 or bt_glass.mp3 to any other file names stops the app from running. No error, it just stops. The new sound file is in the sound folder. I cleaned the project, restarted with the same result. https://www.dropbox.com/s/i65ggjq33czh0yg/app_error.png?dl=0 Anything obvious that is incorrect? Cheers,
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/09/15 04:29 PM (8 years ago)
Did you try 'adding' another line rather than changing one? I think those particular sounds are used in 'some' area of the project, and if changed, will mess up the mojo... Cheers! -- Smug
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
06/09/15 10:28 PM (8 years ago)
Yes, I have tried adding a line with a new sound reference but the mojo still got messed up.... Cheers Farcat
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/09/15 10:35 PM (8 years ago)
Don't want to sound silly, but you *are* 'adding' the sound files like other Xcode resources, right? Otherwise, it should act like any other sound effect... just add another line to put it into the sound effect 'array'... Cheers! -- Smug
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
06/09/15 10:50 PM (8 years ago)
That's what I thought but it just doesn't like the extra line: //fill an array of sound effect file names... [appDelegate setSoundEffectNames:[[NSMutableArray alloc] init]]; [appDelegate.soundEffectNames addObject:@"bt_funk.mp3"]; [appDelegate.soundEffectNames addObject:@"bt_glass.mp3"]; becomes //fill an array of sound effect file names... [appDelegate setSoundEffectNames:[[NSMutableArray alloc] init]]; [appDelegate.soundEffectNames addObject:@"bt_funk.mp3"]; [appDelegate.soundEffectNames addObject:@"bt_glass.mp3"]; [appDelegate.soundEffectNames addObject:@"new_sound.mp3"]; I also added new_sound.mp3 in the sound folder. Thanks, Farcat
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/09/15 11:09 PM (8 years ago)
Well, it looks like it should work. If it doesn't work, then make sure your 'quotes (") are the 'right kind' of quotes. Did you type that in Xcode, or did you paste it from somewhere else? Sometimes, depending on my editor, I get 'slanted' quotes, which are the wrong character for Xcode. Just tried it in a project of mine, with no issues... Added Los Lobos' "One Time, One Night". Granted, a little longer than your typical Sound Effect, but it worked just fine. Added the filename to the array, as we discussed above. In my 'viewDidLoad' (although anywhere is probably fine) beaconinventory_appDelegate *appDelegate = (beaconinventory_appDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate playSoundEffect:@"mySound.mp3"]; and off it went. Check your files, check your syntax. The theory is pretty sound, so it's gotta be something else... Cheers! -- Smug
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
06/10/15 12:03 AM (8 years ago)
I'll be damned, I still can't get the sound to fire up :( I checked the syntax, the files, made sure I had the right kind of quotes. Added the filename to the array (first tried in 'viewDidLoad', then in 'loadSoundEffects' where the other sounds) and still no sound. Xcode can be a tad frustrating sometimes... I am just wondering, in the BT_loadConfigDataViewController.m file the current code to play the sound is: [appDelegate.soundEffectNames addObject:@"bt_funk.mp3"]; whereas you are using: [appDelegate playSoundEffect:@"new_sound.mp3"]; Does soundEffectNames means that there should be a reference to that name somewhere else? I am using this sound with Strobe's iPad Story Book Page plugin. DO you reckon it could be something to do with the plugin? Thanks, Farcat
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/10/15 01:39 AM (8 years ago)
I'm not sure if that's a typo, or if that's what you're actually using... But the code you put up in your example is the 'add to array' command, not the 'play' command. If you're being literal, then that would be one line you want to comment out, and replace with my line ;) If you're not being literal, then I'm not sure; in 'other' parts of the BT Core that's how they play it, so that's how I play it. Try it your way, and try it my way, and see if either is better than the other. :) Cheers! -- Smug
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
06/10/15 04:52 AM (8 years ago)
Thanks Smug, OK, I now see the difference. if I use [appDelegate.soundEffectNames addObject:@"new_sound.mp3"]; the app doesn't run: https://www.dropbox.com/s/lq6evu5vfrkpfsn/Screen%20Shot%202015-06-10%20at%2013.01.42.png?dl=0 https://www.dropbox.com/s/ylfrzmm0xlz52nq/Screen%20Shot%202015-06-10%20at%2013.07.07.png?dl=0 If I use [appDelegate playSoundEffect:@"new_sound.mp3"]; the app runs and there are no mistakes. Looks like your way might be better, at least the app launches but the sound still doesn't play (and my volume is on...) Gotta keep digging :)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/10/15 05:25 AM (8 years ago)
Play the mp3 'outside' of the app, and make sure it plays ok. If so, then inside your app 'should' be no different. If it doesn't error, throw a few 'bt_debugger' statements around to 'follow' the sound, or what you think should be the sound, and see if everything flows the way it should. Let us know how things turn out. Cheers! -- Smug
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
06/10/15 12:32 PM (8 years ago)
Thanks Smug, I have submitted the app without the sound for now. Once it is on the app store I'll try again playing around to see if I can make the sound work. Cheers, Farcat
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.