Web Audio API, delay doesn't work

388 views
Skip to first unread message

macrojd

unread,
Nov 11, 2012, 6:43:39 PM11/11/12
to chromiu...@chromium.org

Hi guys. I'm still checking a few APIs and I came across a little problem with Web Audio. I can't make the delay node work. I created the source, connected the source to the delay node and the not to the destination. I also connected the source to the destination to here both sounds, but the sound with the delay never gets to the speakers. I tries the same pattern in two different application. In http://ykifle.github.com/audiograph/ it doesn't work like in my script (once you set the delay to something different than 0 you only get silence). And at http://webaudioplayground.appspot.com, the delay works, but it can't be set for more than 1 second.

Apparently there is a way to make it work, but I can't find the way. Here is my play() function:

function play(mybuffer){
  var sourceNode = context.createBufferSource();
  sourceNode.buffer = mybuffer;

  delayNode = context.createDelay();
  delayNode.delayTime.value = 0.5;

  sourceNode.connect(context.destination);
  sourceNode.connect(delayNode);
  delayNode.connect(context.destination);
  sourceNode.start(0);
}


I also tried to set several delays with the AudioParam methods, but didn't work. As soon as I declare a value for the delay, I get silence.

Am I missing something?

Thanks
JD

Chris Wilson

unread,
Nov 12, 2012, 11:30:40 AM11/12/12
to macrojd, chromiu...@chromium.org
Hey JD - 
From the symptoms, I'm presuming you're getting a script error somewhere.  Can you either send me the full code, or (better yet) point me to a web address where it's posted?

(I wrote the Web Audio Playground, BTW - the delay being limited to 1.0 second there is only a UI limit.  It was hard to select small "echo"-style delay values easily otherwise.)

-C



--
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-html5/-/L-6VNumkkcwJ.
To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-html5/?hl=en.

macrojd

unread,
Nov 12, 2012, 3:49:09 PM11/12/12
to chromiu...@chromium.org, macrojd

Hi Chris. Sure I know who you are, I first learned the API thanks to your video from Google I/O!

Here is the link to my script. It was extremely simplified because is an example I'm preparing for my book and the examples are always minimized for didactic purposes.


The script doesn't return any error, but probably the construction is wrong because it is my first try with delays. I tried the same construction at http://ykifle.github.com/audiograph/ and it doesn't work either, so I suppose he is having the same problem I have.

JD

macrojd

unread,
Nov 12, 2012, 6:56:25 PM11/12/12
to chromiu...@chromium.org, macrojd
Hi Chris. Well, I found out that the problem is only with that particular file (gunshot.wav). I replaced the file by another one and it worked!

I'll try with more files to check if it was a corrupt file or something like that.

JD

Chris Wilson

unread,
Nov 12, 2012, 7:00:59 PM11/12/12
to macrojd, chromiu...@chromium.org
Heh.  I sent mail internally one minute before you did.

It doesn't seem to be that file alone; I replicated it with another audio file.  However, when I converted the file to mono, it worked correctly.  It appears to be getting cut off (that is, the delay node stops producing audio) when the original buffer source ends.


Reply all
Reply to author
Forward
0 new messages