Skip to content

Time Accuracy: frequency changed on boundary will cause sample value shift #13

@6769

Description

@6769

Problem

Every time frequency changed, the remain part of last frequeny lost_Δt ≤ frequency_duration%(1/sample_frequency) will be dropped, in example graph which is between last frequency black sample dot (t<2) and frequeny change point (t=2).

Code Time Function: Brown
Real Mathematica Function: Blue
sinNx2

I think the real next sample value should be sampled at the red star,
and the lost part should be very minor so that it's usually hard to distinguish the effect.

Cause

The time lost happens on these codeMode.java, especially the force (int) cause lost

protected int convertMsToSamples(double durationMs) {
        return (int) Math.round(durationMs * mSampleRate / 1000.0);
    }

    protected void setTone(double frequency) {
        mRunningIntegral += 2.0 * frequency * Math.PI / mSampleRate;
        mRunningIntegral %= 2.0 * Math.PI;
        mOutput.write(Math.sin(mRunningIntegral));
    }

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