rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.89k stars 160 forks source link

Default hold param for new Wad #91

Closed FireEagle25 closed 5 years ago

FireEagle25 commented 6 years ago

Hello, thank you for great library.

So, I tried to use Wad.js for playing the 1-minute mp3-file. And the file was stopped after something 3 seconds every time. I found the issue about the hold param.

If it can be possible, add some information to readme about so important thing. Thx.

rserota commented 6 years ago

Normally, when you create a wad that uses an audio file as the source, the hold parameter for that wad will automatically be set to the duration of the audio clip, provided you didn't manually override the hold parameter with a different value. I just tested this feature today, and it seems to work as intended; I'm able to play a full song without specifying any parameters, aside from the source.

    var fullSong = new Wad({source:'./the-chase.mp3'})
    fullSong.play()

If you'd like to share a small piece of code that reproduces this issue, I might be able to help you further.

FireEagle25 commented 6 years ago

Okey, that's my code:

test_sound = new Wad({ source: 'sounds/test_sound.wav');
function SetLastData(data) {
        data = JSON.parse(data);
        if (data.data == "test-audio") {
            test_sound.play();
        }
}

Sometimes, I execute function SetLastData (When web-socket-event fired). And all is okey, but duration of track is 1 minute and playing time is something about 3 seconds. When I set hold param to 61, playing time is 1 minute.

Link to full script with my additional logic. Script contain 62 strings of code.

rserota commented 6 years ago

I tried testing this out further after reviewing your code, and I'm still unable to reproduce this issue.

Based on your code, it seems like you're trying to make a mobile application, so I tried testing it on my iPhone, and everything still seems to work normally. However, looking at, MDN, (https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/duration) it says that safari for iOS has 'questionable' support for the audioBuffer duration property. Maybe if you're using an older phone with an older browser, it can't detect the length of the audio clip? That's my best guess.

Either way, thanks for using Wad.js, and thanks for raising this issue.

FireEagle25 commented 6 years ago

Hmm, I don't think Galaxy S8 is the old phone with old browser, but everything is possibly with this Android devices (I have one). Either way, thanks for your library, it's very helpful for me.