microsoft / microsoft/pxt

decodeInstrument in music.ts does not consider offset for amp and pitch LFO's amplitude

Open Beginner friendly
#11,330 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
641
Avg merge
12h 4m
Merged PRs (30d)
57

Description

    function decodeInstrument(buf: Uint8Array, offset: number): Instrument {
        return {
            waveform: buf[offset],
            ampEnvelope: {
                attack: get16BitNumber(buf, offset + 1),
                decay: get16BitNumber(buf, offset + 3),
                sustain: get16BitNumber(buf, offset + 5),
                release: get16BitNumber(buf, offset + 7),
                amplitude: get16BitNumber(buf, offset + 9),
            },
            pitchEnvelope: {
                attack: get16BitNumber(buf, offset + 11),
                decay: get16BitNumber(buf, offset + 13),
                sustain: get16BitNumber(buf, offset + 15),
                release: get16BitNumber(buf, offset + 17),
                amplitude: get16BitNumber(buf, offset + 19),
            },
            ampLFO: {
                frequency: buf[offset + 21],
                amplitude: get16BitNumber(buf, 22)  // here
            },
            pitchLFO: {
                frequency: buf[offset + 24],
                amplitude: get16BitNumber(buf, 25)  // here
            },
            octave: buf[offset + 27]
        }
    }

They appear that they should be get16BitNumber(buf, offset + 22) and get16BitNumber(buf, offset + 25) similar to the LFO frequencies and envelopes and waveform.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open pxtlib/music.ts and inspect decodeInstrument, focusing on the ampLFO and pitchLFO amplitude reads identified in the issue. Compare them with the surrounding offset-based envelope and frequency reads; done means both LFO amplitudes are decoded relative to the supplied offset.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
audio-video-rtc
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.