Navigation

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

    playAudio() and playNote() do not play well together

    Bug Reporting (Forum)
    3
    5
    438
    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.
    • spikey
      spikey F last edited by spikey

      I encountered this, when using playAudio() and playNote() on the same channel:
      a) If you use playAudio() first, the first call to playNote() afterwards does not play anything, but the second call works again.
      b) If you use playNote() first, the playAudio() call is played, using the ADSR setting (I assume) from the playNote() command: in my example below, it fades in and out very quickly before the sample could be played to the end. The workaround is using setADSR() manually to adjust the channel again. But because there is no "reset" parameter for setADSR(), you would have to use parameters that fit your sample speed. So, better not use playAudio() on the same channel after a playNote().

      Examples:
      This just plays the sample one time by fading it in and out quickly and cutting it before it plays to the end:
      This shows how the sample is not played properly after the playNote() command

      f = 390
      v = 0.5
      p = 0.5
      ch = 0
      w = 0
      l = 2
      s = 1
      
      sample = loadAudio("David Silvera/jingle_level_complete_03")
      print("Start playing...")
      print()
      playNote(ch, w, f, v, l, p)
      // does not matter how much time passes here
      playAudio(ch, sample, v, p, s, 2) // should play the sample 3 times but plays it only once, with a quick fade in and out
      sleep(10)
      

      This plays nothing:

      playAudio(ch, sample, v, p, s, 2) 
      // does not matter how much time passes here
      playNote(ch, w, f, v, l, p)
      sleep(10)
      

      Workaround to make playNote() work again after playAudio() (on the same channel):

      playAudio(ch, sample, v, p, s, 2) 
      sleep(5) // plays the sample twice and the 3rd time it is aborted, what is ok
      playNote(ch, w, f, v, l, p) // but this tone is never heard
      sleep(10) // in praxis you can apply a very small value, like 0.01 instead of 10, but maybe this depends on the note length
      playNote(ch, w, f, v, l, p) // this tone is fine again
      

      So, no worries, if you don't switch on the same channel between playing music and playing samples.

      Hope this was useful.

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

        I have noticed this too, but forgot to report it. It would be great to have this fixed.

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

          I'm not quite sure I understand the workaround? Are the sleeps necessary, or is it just that you need to insert an extra playNote after playAudio before playNote starts to work again?

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

            You don't need that long sleeps, most important is the extra playNote(), but you have to wait at least a little bit of time, I think I tried sleep(0.01) and it worked already.

            1 Reply Last reply Reply Quote 1
            • Kat
              Kat Fuze Team last edited by

              Thank you for the report and for the examples! I've logged the issue.

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