3 Replies Latest reply on Jul 18, 2006 8:04 AM by Newsgroup_User

    starting sound at a cuepoint

    Opera Rat
      I use the same sound file for many different things. Is it possible to just play the sound from one cuepoint to the next? Is it possible to start the sound from a cuepoint so many seconds within the sound instead of from the beginning of the sound file? Like start play at cuepoint "cue7".
        • 1. Re: starting sound at a cuepoint
          Level 7
          On Sun, 16 Jul 2006 04:43:21 GMT, Opera Rat posted in
          macromedia.director.lingo:

          > I use the same sound file for many different things. Is it possible to
          > just play the sound from one cuepoint to the next? Is it possible to
          > start the sound from a cuepoint so many seconds within the sound instead
          > of from the beginning of the sound file? Like start play at cuepoint
          > "cue7".

          I find that sound(queue) is the best method for this - even if you only
          want to start from a specific time. Check the help docs for details.

          Just to illustrate, copy the following into a behavior and drop it on a
          button sprite. You'll need to replace my hard-coded
          member("cuePointSounds") with your sound member in two places.

          -- behavior script
          property pSoundMem
          property pSoundChannel
          property pCueNames
          property pCueTimes
          property pInpoint
          property pOutpoint

          on beginSprite me
          pSoundMem = member("cuePointSounds")
          pCueNames = pSoundMem.cuePointNames
          pCueTimes = pSoundMem.cuePointTimes
          end

          on mouseUp me
          sound(pSoundChannel).queue([#member: pSoundMem,\
          #startTime: pCueTimes[pCueNames.getPos(pInPoint)],\
          #endTime: pCueTimes[pCueNames.getPos(pOutPoint)]]\
          )
          sound(pSoundChannel).play()
          end

          on getPropertyDescriptionList me
          lCueNames = member("cuePointSounds").cuePointNames
          pList = [:]

          pList[#pInpoint] = [#comment:"Select a start cuePoint"]
          pList[#pInpoint][#format] = #string
          pList[#pInpoint][#default] = lCueNames[1]
          pList[#pInpoint][#range] = lCueNames

          pList[#pOutpoint] = [#comment:"Select a stop cuePoint"]
          pList[#pOutpoint][#format] = #string
          pList[#pOutpoint][#default] = lCueNames[lCueNames.count]
          pList[#pOutpoint][#range] = lCueNames

          pList[#pSoundChannel] = [#comment:"Select a sound channel"]
          pList[#pSoundChannel][#format] = #integer
          pList[#pSoundChannel][#default] = 2
          pList[#pSoundChannel][#range] = [#min:1,#max:8]

          return pList
          end
          -- end of behavior script

          The basic premise is that it sets the startTime and stopTime by utilizing
          member().cuePointNames and member().cuePointTimes (also in the docs). It
          does this by finding the index position of your selected cuePointName in
          the list of cuePointNames (using getPos) and setting the startTime to the
          same index in the list of cuePointTimes.



          HTH


          --
          Mark A. Boyd
          Keep-On-Learnin' :)
          • 2. Re: starting sound at a cuepoint
            Opera Rat Level 1
            Now I'm using an mp3 file without embedded cuepoints. It looks like I somehow define my cue points in director in a member, if I'm understanding your code. How would I define cuepoint times and names in director?
            • 3. Re: starting sound at a cuepoint
              Level 7
              On Tue, 18 Jul 2006 03:53:18 GMT, Opera Rat posted in
              macromedia.director.lingo:

              > Now I'm using an mp3 file without embedded cuepoints. It looks like I
              > somehow define my cue points in director in a member, if I'm
              > understanding your code. How would I define cuepoint times and names in
              > director?

              That does get more complicated since MP3 doesn't support cuepoints and you
              can't add them to the member.

              For cases like this, it's best to create your own list (or lists) with the
              names and times in milliseconds.

              Just some pseudo code, but I hope it illustrates what I mean.

              cpList = [#joe_in:0, #joe_out:5000, #jane_in:5001, #jane_out:15000]

              sound(pSoundChannel).queue([#member: pSoundMem,\
              #startTime: cpList[#joe_in],\
              #endTime: cpList[#joe_out)]\
              )

              Of course, you could create two separate lists if you want it to work similar
              to the member list properties.


              --
              Mark A. Boyd
              Keep-On-Learnin' :)