Skip to content

onset seems off by ~50ms #4

Description

@weepy

Hi I was trying on the onset detection, which seems pretty decent BTW. I was running it offline, just piping in some mono PCM. Essentially I want to auto slice some samples based on their onsets. On all three of the samples I found that it found the peaks well enough, but reported them ~2400 samples too late. I understand that because it's streaming that you will always essentially be late, but is this expected in terms of the delay I should try to subtract ?

Here's my code

    var onsetdetector = new MMLLOnsetDetector(44100)
 

    fetch("pianomelody.wav")
        .then((response) => {
            return response.arrayBuffer()
        })
        .then(data => {
            const context = new (window.AudioContext || window.webkitAudioContext)();
            context.decodeAudioData(data, (buffer) => {
                run(buffer.getChannelData(0))
            })
        })
    
    function run(data) {
        const CHUNK = 16
        const buffers = sliceBuffer(data, CHUNK)

        for(let i=0; i<buffers.length;i++) {
            const buffer = buffers[i]
            const detection = onsetdetector.next(buffer)
            if(detection) {
                console.log("d", i*CHUNK/44100-0.054)
            }
        }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions