Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Sound speed

    Beginners
    4
    12
    601
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LinkCraft
      LinkCraft F last edited by

      Can you change the speed of audio while it’s playing?

      1 Reply Last reply Reply Quote 1
      • waldron
        waldron F last edited by

        //global
        speed = 1
        loop
        clear()
        playAudio( channel, handle, volume, pan, speed, loops )

        if c.a then
        speed+= 1
        endif

        1 Reply Last reply Reply Quote 0
        • vinicity
          vinicity F last edited by vinicity

          If you are talking about playing asset sounds with playAudio(), I'm pretty sure that you cannot change the speed while the audio is already playing. I tried this in my entry for the Speed themed game jam, but couldn't find a way to do it...

          Running waldron's code above restarts the audio for each loop, which you probably do not want.

          One idea I had at the time was to have the same audio playing on different channels, but at slightly different speed, and then slowly cross fade from one to the other by changing the volume of both channels (volume can be changed while its playing with setVolume()).

          I guess it depends on the audio, if it would be possible to make that sound OK...

          waldron 1 Reply Last reply Reply Quote 0
          • waldron
            waldron F @vinicity last edited by

            This post is deleted!
            vinicity 1 Reply Last reply Reply Quote 0
            • vinicity
              vinicity F @waldron last edited by

              @waldron No, I just tested it. The audio definitely restarts every time you call playAudio().

              waldron 1 Reply Last reply Reply Quote 0
              • waldron
                waldron F @vinicity last edited by

                This post is deleted!
                vinicity 1 Reply Last reply Reply Quote 0
                • vinicity
                  vinicity F @waldron last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • PickleCatStars
                    PickleCatStars F last edited by

                    What happens if you setfrequency the channel the audio’s playing on?

                    vinicity 1 Reply Last reply Reply Quote 0
                    • vinicity
                      vinicity F @PickleCatStars last edited by

                      @toxibunny I just tested it, and it actually works!

                      Now I feel stupid.I just kept looking for a setSpeed() command, since the parameter to playAudio() is called speed!

                      1 Reply Last reply Reply Quote 1
                      • vinicity
                        vinicity F last edited by

                        You can use setFrequency with a frequency parameter that goes from 0 (the sounds then stops playing) and upwards. Setting it to 1 means playing at normal speed. So the parameter isn't really a frequency, but seems to correspond to the speed parameter from playAudio()!

                        I tested this:

                        music = loadAudio("...")
                        playAudio(0, music, 1, .5, 1, -1)
                        freq = 1
                        loop
                           clear()
                           c = controls(0)
                           freq += c.ly / 100
                           print(freq)
                           setFrequency(0, freq)
                           update()
                        repeat
                        

                        ...and then you can control the speed of the music with the left stick while it is playing!

                        1 Reply Last reply Reply Quote 2
                        • waldron
                          waldron F last edited by

                          maybe i need my weetabix haha glad you found a solution

                          1 Reply Last reply Reply Quote 2
                          • LinkCraft
                            LinkCraft F last edited by

                            Thanks I’ll try it out

                            1 Reply Last reply Reply Quote 1
                            • First post
                              Last post