1 2 Previous Next 46 Replies Latest reply on Jun 17, 2013 4:48 PM by designedbyjackley

    Call Sound from a Symbol

    PEPPERFACE Level 1

      Does anyone have any experience of using buzz.js to add audio to animations?

       

      It's a great bit of kit and it works really well, but I'm having trouble calling sound from anything other than code placed on the main timeline. If I try and trigger a sound to play when, for example, a button within a symbol is clicked, nothing happens.

       

      I don't suppose anyone knows if it's possible?

       

      Cheers in advance x

        • 1. Re: Call Sound from a Symbol
          TimJaramillo Level 4

          Hi Pepperface, it sounds like you are having the same scope problem as this fellow:

           

          http://forums.adobe.com/thread/1170095?tstart=0

           

          Hopefully that thread will help you out.

          1 person found this helpful
          • 2. Re: Call Sound from a Symbol
            PEPPERFACE Level 1

            Aha! I did have a quick read of that post and at first glance it didn't seem to be what I was after, but on closer inspection it looks like you have pointed me back in the right direction.

             

            Huge thanks, Tim, the guidance really is greatly appreciated!

            • 3. Re: Call Sound from a Symbol
              TimJaramillo Level 4

              No problem, Pepper! Let us know how it goes.

              • 4. Re: Call Sound from a Symbol
                PEPPERFACE Level 1

                Hmmmm... I'm going round and round in circles here, now (actually it's worse than that, I think I'm getting further away from my goal than I was when I started out).

                 

                Maybe it's tiredness, maybe it's just plain downright stupidity, but there's something I'm very definitely not seeing or understanding somewhere.

                 

                This is the code that's in compositionReady:-

                 

                var audio01 = new buzz.sound("media/audio01", {formats: [ "ogg", "mp3" ]});

                 

                     audio01.bind('loadeddata', function(e){

                 

                     var stage = Edge.getComposition(compId).getStage();

                 

                });

                 

                If I trigger the sound to be played anywhere on the main timeline using the code: audio01.play(); it runs just fine. However, I just cannot get it to be triggered from within a symbol.

                 

                Having read and re-read the posts about 'scope' (which, I totally agree, is obviously where the problem lies) I'm still wholly failing to write what's needed. I've tried umpteen variations and nothing's worked thus far.

                 

                If there's any kind soul out there who can nudge me towards a solution I'd be eternally grateful. x

                • 5. Re: Call Sound from a Symbol
                  TimJaramillo Level 4

                  Hey Pepper,

                   

                  On compositionReady, change it to this (note the "sym" instead of "var"):

                   

                  sym.audio01 = new buzz.sound("media/audio01", {formats: [ "ogg", "mp3" ]});

                   

                       audio01.bind('loadeddata', function(e){

                   

                       var stage = Edge.getComposition(compId).getStage();

                   

                  });

                   

                   

                  Then, to stop the sound anywhere else in your project:

                  sym.getComposition().getStage().audio01.stop();

                  • 6. Re: Call Sound from a Symbol
                    PEPPERFACE Level 1

                    Ooo, thank you! I'll try that right now and report back!!!

                    • 7. Re: Call Sound from a Symbol
                      PEPPERFACE Level 1

                      Nope, sadly it really didn't like that at all (when run, the animation had a big fit and just played right through without stopping... still sans sound).

                       

                      Still hunting for a fix

                      • 8. Re: Call Sound from a Symbol
                        TimJaramillo Level 4

                        Can you post your project?

                        • 9. Re: Call Sound from a Symbol
                          PEPPERFACE Level 1

                          Two tics... I'll put together a 'test version' as the project I'm working on is fairly huge. Back in a min.

                          • 10. Re: Call Sound from a Symbol
                            PEPPERFACE Level 1

                            Hi again, Tim... okay well to try and make things less unweidly for you I've created a bare-bones test project.

                             

                            Its zipped in a dropbox here.

                             

                            I've reproduced everything that's working and not working; so it's a true representation of what's casuing me such difficulty. If you can shed an light on any of it you'll be able to hear me cheering from here!

                            • 11. Re: Call Sound from a Symbol
                              TimJaramillo Level 4

                              Hi Pepper.

                               

                              In your bare bones example, you didn't put the code to setup buzz audio, so I copied the example I gave you (with sym.audio01, etc).

                               

                              Then per my example, I added this line to the nested button (the bottom button):

                               

                              sym.getComposition().getStage().audio01.play();

                               

                              And this plays the audio fine. Perhaps you didn't add the above line to your button?

                               

                               

                              Source:

                              http://www.timjaramillo.com/code/edge/_source/sound_test_buzzJS.zip

                              • 12. Re: Call Sound from a Symbol
                                PEPPERFACE Level 1

                                Wow! Tim, I have NO IDEA what or how you've done what you've done but you're absolutely right, it works LIKE A CHARM!!!

                                 

                                My profoundest apologies for not being more specific about the files I uploaded, they were an example of what wasn't working based on my original efforts. I did, on a couple of alternative versions, try all you suggested re: changing var for sym etc, but for some reason (unquestionably errors on my part!) it just wouldn't function when I did it.

                                 

                                Anyway, the bottom line, here, is that I really cannot thank you enough for your time and your stirling advice. Hopefully others out there who are experiencing similar, sound frustrations will also be able to derive benefit from this discusssion and the files. And in the meantime I'm off to thoroughly study your brilliant, edited version!

                                 

                                Thank you so much!!!

                                 

                                x

                                • 13. Re: Call Sound from a Symbol
                                  TimJaramillo Level 4

                                  Awesome, glad to be of help! Good luck with the rest of your project!

                                  • 14. Re: Call Sound from a Symbol
                                    PEPPERFACE Level 1

                                    Hi Tim... if you're out there??? I'm so sorry to keep haunting you with this but I've spent the last 14 hours getting nowhere and I'm utterly floundering.

                                     

                                    Your brilliantly edited file works perfectly with one audio track but I need to add several. I've tried innumerable permutaions of the following code (in compositionReady) but only the first, listed audio is ever recognised and/or can be played. I hate to put upon your time more than I already have; but I was wondering if you could let me know if what I'm attempting is even posssible (in which case I'll soldier on trying for a fix) or if it's not (in which case I can finally go and get some much needed sleep ).

                                     

                                    Many thanks, in advance, for any light you can shed!

                                     

                                    Below is the latest in a long line of code variations that don't work, except that  sym.audio01 works fine every time and is able to be played in a whole host of ways... the others, though? Nothing doing.

                                     

                                     

                                    sym.audio01 = new buzz.sound("media/audio01", {formats: [ "ogg", "mp3" ]});

                                     

                                         audio01.bind('loadeddata', function(e){

                                     

                                         var stage = Edge.getComposition(compId).getStage();

                                     

                                    });

                                     

                                     

                                    sym.audio02 = new buzz.sound("media/audio02", {formats: [ "ogg", "mp3" ]});

                                     

                                         audio02.bind('loadeddata', function(e){

                                     

                                         var stage = Edge.getComposition(compId).getStage();

                                     

                                    });

                                     

                                     

                                    sym.audio03 = new buzz.sound("media/audio03", {formats: [ "ogg", "mp3" ]});

                                     

                                          audio03.bind('loadeddata', function(e){

                                     

                                         var stage = Edge.getComposition(compId).getStage();

                                     

                                    });

                                     

                                     

                                    sym.audio04 = new buzz.sound("media/audio04", {formats: [ "ogg", "mp3" ]});

                                     

                                         audio04.bind('loadeddata', function(e){

                                     

                                          var stage = Edge.getComposition(compId).getStage();

                                     

                                    });

                                    • 15. Re: Call Sound from a Symbol
                                      TimJaramillo Level 4

                                      Hi Pepper, the below code works. You just need to add "sym" to the bind method, to get the scope synced up.

                                       

                                      sym.audio01 = new buzz.sound("media/audio01", {formats: [ "ogg", "mp3" ]});

                                      sym.audio01.bind('loadeddata', function(e){

                                           var stage = Edge.getComposition(compId).getStage();

                                      });

                                       

                                       

                                      sym.audio02 = new buzz.sound("media/audio02", {formats: [ "ogg", "mp3" ]});

                                      sym.audio02.bind('loadeddata', function(e){

                                           var stage = Edge.getComposition(compId).getStage();

                                      });

                                      1 person found this helpful
                                      • 16. Re: Call Sound from a Symbol
                                        PEPPERFACE Level 1

                                        Aha!!!  That makes perfect sense!!!  You're a star, cheers, Tim!  Many thanks once again x

                                        • 17. Re: Call Sound from a Symbol
                                          TimJaramillo Level 4

                                          No problem! Good luck with your project!

                                          • 18. Re: Call Sound from a Symbol
                                            sito.bernal

                                            Hi there,

                                             

                                            I'm new to this forum (at least, this is my first post).

                                            I've been trying to make sound work in an edge animate sequence using your code, but it doesn't work at all. I've downloaded TimJaramillo's sound_test project from http://forums.adobe.com/message/5152110#5152110#5152110. I've disemboweled it, and put the code both on the stage and a button, changing "var audio01" to "var audioTitulo" and the path "media/audio01" to "media/titulo" (since my audio files are "titulo.mp3" and "titulo.ogg"). But it's not working.

                                             

                                            You can find my project here. Code for playing the sound is in time 00:02,750, as a timeline action.

                                             

                                            Any idea?

                                             

                                            Thank you so much for your help, in advance

                                            • 19. Re: Call Sound from a Symbol
                                              TimJaramillo Level 4

                                              Hi there. The problem is that your are currently not loading the buzz js library.

                                               

                                              Put the below line in your html file, right before the </head> tag:

                                               

                                              <script type="text/javascript" charset="utf-8" src="buzz.js"></script>

                                              • 20. Re: Call Sound from a Symbol
                                                sito.bernal Level 1

                                                Thank you so much for answering.

                                                 

                                                I forgot to include that line in the project I sent (it's smaller than the one I'm working on).

                                                 

                                                I've included the code but still doesn't work (The project with the line added). Also, I've waited for if the sound played by itself, but got no results.

                                                 

                                                Thanks again for your help

                                                • 21. Re: Call Sound from a Symbol
                                                  TimJaramillo Level 4

                                                  Hi there, you also have a stop action on a trigger on the timeline at 185 milliseconds, so the timeline never hits the 2.75 second trigger.

                                                   

                                                  Here is a working version of your file:

                                                  http://www.timjaramillo.com/code/edge/_temp/EDGE_UP-DOWN.zip

                                                  • 22. Re: Call Sound from a Symbol
                                                    sito.bernal Level 1

                                                    I'm aware of that stop action. But there is a button for having the timeline running and hit that trigger... Does this mean that sound can only be played in plain, "non-interactive", animations?

                                                    • 23. Re: Call Sound from a Symbol
                                                      PEPPERFACE Level 1

                                                      Hi there... really sorry that I haven't chipped in to this conversation more swiftly (for some reason I didn't get a notification, until just now, that the thread had been added to). Tim's obviously done a fab working version but I'll also have a look at your problem and see if there's any info (and/or demo files) that I can provide for extra assistance. Back in touch soon

                                                      • 24. Re: Call Sound from a Symbol
                                                        PEPPERFACE Level 1

                                                        Hi again... you were so close. Just a tiny bit of code missing.

                                                         

                                                        On your timeline trigger at 0.02.750 you have the following:-

                                                         

                                                        audioTitulo.play();

                                                         

                                                        When it needs to be:-

                                                         

                                                        sym.audioTitulo.play();

                                                         

                                                        Prefixing with 'sym' correctly references the audio.

                                                         

                                                        I've put a working verison of your file here:

                                                        https://www.dropbox.com/s/fcvgrjotssja1lz/EDGE_UP-DOWN-SYM_ADDED.zip

                                                        • 25. Re: Call Sound from a Symbol
                                                          sito.bernal Level 1

                                                          Hi again!

                                                          TimJaramillo, Pepperface, thank you so much for help.

                                                           

                                                          But I'm still having issues with the sound... I mean, it works perfect at this point, but I must add a speech for every sentence. So I've copied the code to add a new speech having this code

                                                          sym.audioTitulo = new buzz.sound("media/titulo", {formats: [ "ogg", "mp3" ]});

                                                                audioTitulo.bind('loadeddata', function(e){

                                                                var stage = Edge.getComposition(compId).getStage();

                                                          });

                                                           

                                                          sym.frase_01 = new buzz.sound("media/frase_01", {formats: [ "ogg", "mp3" ]});

                                                                     frase_01.bind('loadeddata', function(e){

                                                                    var stage = Edge.getComposition(compId).getStage();

                                                                     });

                                                          on the stage, and this one

                                                          sym.frase_01.play();

                                                          triggering at 0.11.000, so when the timeline counter gets the trigger, frase_01.ogg or frase_01.mp3 should playback.

                                                           

                                                          Every media works perfectly (I've tried them all by changing "media/fileName" to each file, and they're played correctly.

                                                          The thing is that it won't play when declaring more than one file. Am I missing something or is there a way of declaring multiple assets so they can be played on the timeline or when hitting a button?

                                                           

                                                          Thank you very much in advanced, again.

                                                           

                                                          Here's the project with the above code.

                                                          • 26. Re: Call Sound from a Symbol
                                                            TimJaramillo Level 4

                                                            Not sure if this will solve your issue, but you need to add "sym" to the "bind" line for each sound:

                                                             

                                                            sym.audioTitulo = new buzz.sound("media/titulo", {formats: [ "ogg", "mp3" ]});

                                                             

                                                            sym.audioTitulo.bind('loadeddata', function(e){

                                                                  var stage = Edge.getComposition(compId).getStage();

                                                            });

                                                            • 27. Re: Call Sound from a Symbol
                                                              PEPPERFACE Level 1

                                                              Well spotted, Tim...

                                                              • 28. Re: Call Sound from a Symbol
                                                                sito.bernal Level 1

                                                                That sym was exactly what I needed! Now it works perfect! You can take a look at www.digitalstooges.com/algaida.

                                                                In english:

                                                                 

                                                                UP AND DOWN

                                                                 

                                                                Peloncho and his friend, ladybug, are playing hide and seek in the park

                                                                 

                                                                Ladybug can't find Peloncho, as he has climbed up the lampost. Peloncho is now UP the lampost.

                                                                 

                                                                Peloncho has hidden behind the bench. Peloncho is now DOWN the lampost.

                                                                 

                                                                Peloncho has climbed up the lampost, again. Now he's UP the lampost.

                                                                 

                                                                Peloncho is now DOWN the lampost.

                                                                 

                                                                Hey, Peloncho! Ladybug finally found you!

                                                                 

                                                                 

                                                                 

                                                                 

                                                                Thank you very much, indeed!

                                                                • 29. Re: Call Sound from a Symbol
                                                                  TimJaramillo Level 4

                                                                  Glad you got it working! That's a fun project you're building.

                                                                  • 30. Re: Call Sound from a Symbol
                                                                    PEPPERFACE Level 1

                                                                    asgdasdgasdfgasdf your project looks wonderful. Well done - and every success to you for future work

                                                                    • 31. Re: Call Sound from a Symbol
                                                                      designedbyjackley

                                                                      Hey Tim,

                                                                       

                                                                      I was trying to load the buzz.js using the yep nope method like I do everything else and taking the link out of the head tag and it no longer works ... do you know why this is happening?

                                                                       

                                                                      // insert code for compositionReady event here

                                                                      yepnope({nope:['edge_includes/jquery-ui-1.10.2.custom.min.js','edge_includes/jquery.ui.tou ch-punch.min.js','edge_includes/buzz.js'], complete: init});

                                                                       

                                                                       

                                                                      function init (){

                                                                       

                                                                      sym.audio01 = new buzz.sound("media/FryChoir_Jazz_56k_ST_053013", {formats: [ "ogg", "mp3" ]});

                                                                           audio01.bind('loadeddata', function(e){

                                                                           var stage = Edge.getComposition(compId).getStage();

                                                                       

                                                                      });

                                                                       

                                                                      audio01.load();

                                                                       

                                                                      }

                                                                      • 32. Re: Call Sound from a Symbol
                                                                        TimJaramillo Level 4

                                                                        Hi there, are you getting any errors in your console log?

                                                                         

                                                                        Is the "init" function being called (are all the files loading)?

                                                                        • 33. Re: Call Sound from a Symbol
                                                                          designedbyjackley Level 1

                                                                          Yeah its giving me an error when it first calls the "new buzz.sound"

                                                                           

                                                                          Uncaught ReferenceError: buzz is not defined

                                                                           


                                                                          • 34. Re: Call Sound from a Symbol
                                                                            designedbyjackley Level 1

                                                                            Actually I realized I had left a duplicate version of:

                                                                             

                                                                            ym.audio01 = new buzz.sound("media/FryChoir_Jazz_56k_ST_053013", {formats: [ "ogg", "mp3" ]});

                                                                                 audio01.bind('loadeddata', function(e){

                                                                                 var stage = Edge.getComposition(compId).getStage();

                                                                             

                                                                            });

                                                                             

                                                                            loose in the directly in the Stage and within composition ready... once I removed that its working but I'm still getting a similar error:

                                                                             

                                                                            Uncaught ReferenceError: audio01 is not defined

                                                                            • 35. Re: Call Sound from a Symbol
                                                                              TimJaramillo Level 4

                                                                              Try this (you're missing sym.audio in 3rd line):

                                                                               

                                                                              sym.audio01 = new buzz.sound("media/FryChoir_Jazz_56k_ST_053013", {formats: [ "ogg", "mp3" ]});

                                                                               

                                                                               

                                                                              sym.audio01.bind('loadeddata', function(e){

                                                                              var stage = Edge.getComposition(compId).getStage();

                                                                               

                                                                              });

                                                                              • 36. Re: Call Sound from a Symbol
                                                                                designedbyjackley Level 1

                                                                                Yup and I also needed to add it when I loaded the sound as well!

                                                                                 

                                                                                sym.audio01.load();

                                                                                 

                                                                                So just so I understand, everytime I reference "audio01" I need to include the sym. before hand correct?

                                                                                • 37. Re: Call Sound from a Symbol
                                                                                  TimJaramillo Level 4

                                                                                  In your specific case, yep- pretty much.

                                                                                   

                                                                                  It's a scope thing- in your example, when you create the variable "audio01", you're creating it in the scope of "sym":

                                                                                   

                                                                                  sym.audio01 = new buzz.sound( ...

                                                                                   

                                                                                  So whenever you refer to that variable, you have to first go to the "sym" scope, like this:

                                                                                   

                                                                                  sym.audio01...

                                                                                  • 38. Re: Call Sound from a Symbol
                                                                                    designedbyjackley Level 1

                                                                                    Got it THX Tim!

                                                                                     

                                                                                    Really appreciate all your insight & knowledge

                                                                                    • 39. Re: Call Sound from a Symbol
                                                                                      TimJaramillo Level 4

                                                                                      No problem, glad to help!

                                                                                      1 2 Previous Next