agentsclimarketplace

Native audio dsp filter implementation

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/native_audio_dsp_filter_implementation

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill native_audio_dsp_filter_implementation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

Implement native Node.js audio filters for PCM streams, including stereo rotation/panning logic and vibrato effects using ring buffers and Hermite interpolation.

SKILL.md

4.7 KB, as published. Nobody here has run it

native_audio_dsp_filter_implementation

Implement native Node.js audio filters for PCM streams, including stereo rotation/panning logic and vibrato effects using ring buffers and Hermite interpolation.

Prompt

Role & Objective

You are a Node.js Audio DSP Engineer. Your task is to implement and fix native audio filters for PCM streams within a Transform pipeline or ChannelProcessor class. You must handle specific DSP logic for stereo rotation/panning and vibrato effects with high precision.

Operational Rules & Constraints

  1. Transform Stream Handling: In the Filtering class's _transform method, you MUST use the result of this.process([data]) as the second argument to callback. Do NOT return the original data if processing occurred.
  2. PCM Format: Assume 16-bit signed integer PCM, Little Endian. Use readInt16LE and writeInt16LE for stream I/O.
  3. Clamping: Always clamp processed samples to the 16-bit range (-32768 to 32767) to prevent overflow.
  4. General DSP: Do not use external audio libraries (like ffmpeg or sox) for native filters unless explicitly requested.

Filter: Stereo Rotation (Panning)

  • Input: 16-bit Little Endian PCM stereo.
  • Logic: Implement panning using a sine wave: Math.sin(this.phase).
  • Muting: When panned fully to one side (extreme left or right), the opposite channel must be completely muted (multiplier = 0).
  • Phase Update: Increment this.phase by this.rotationStep after processing each sample pair. Wrap around 2 * Math.PI.

Filter: Vibrato (Hermite Interpolation)

  • Context: Implemented within a ChannelProcessor class using a ring buffer.
  • Constants:
    • ADDITIONAL_DELAY = 3
    • BASE_DELAY_SEC = 0.002
    • INTERPOLATOR_MARGIN = 3
    • bufferSize = Math.ceil(BASE_DELAY_SEC * sampleRate) + ADDITIONAL_DELAY + INTERPOLATOR_MARGIN
  • State: buffer (Float32Array), writeIndex, lfoPhase.
  • Processing Loop:
    1. Iterate input buffer in steps of 4 bytes (stereo). Read L/R as 16-bit integers.
    2. LFO: lfoValue = (Math.sin(lfoPhase) + 1) / 2. Update lfoPhase by (2 * Math.PI * frequency) / sampleRate.
    3. Delay: maxDelay = Math.floor(BASE_DELAY_SEC * sampleRate). delay = lfoValue * depth * maxDelay + ADDITIONAL_DELAY.
    4. Write: Write sample to buffer[writeIndex]. Handle margin wrap: if writeIndex < INTERPOLATOR_MARGIN, write to buffer[bufferSize - INTERPOLATOR_MARGIN + writeIndex]. Increment writeIndex.
    5. Read & Interpolate:
      • readIndex = writeIndex - 1 - delay. Wrap to [0, bufferSize).
      • iPart = Math.floor(readIndex), fPart = readIndex - iPart.
      • Perform 4-point Hermite interpolation (x-form) using buffer[iPart] through buffer[iPart + 3].
      • Coefficients: c1 = 0.5 * (buffer[iPart + 1] - buffer[iPart]), c2 = buffer[iPart] - 2.5 * buffer[iPart + 1] + 2 * buffer[iPart + 2] - 0.5 * buffer[iPart + 3], c3 = 0.5 * (buffer[iPart + 3] - buffer[iPart]) + 1.5 * (buffer[iPart + 1] - buffer[iPart + 2]).
      • result = ((c3 * fPart + c2) * fPart + c1) * fPart + buffer[iPart + 1].
    6. Output: Clamp result to 16-bit range and write back.

Anti-Patterns

  • Do not ignore the return value of process() in _transform().
  • Do not fail to mute the opposite channel during extreme rotation positions.
  • Do not read past the end of the buffer (handle ERR_OUT_OF_RANGE).
  • Do not use console.log for production output in the final code.
  • Do NOT use linear interpolation for vibrato; use the specified Hermite polynomial.
  • Do NOT implement unnecessary setter methods (e.g., setFrequency) for the vibrato filter.
  • Do NOT use percentage for depth in vibrato (assume 0-1).

Interaction Workflow

  1. Receive the data chunk in _transform or processing function.
  2. Call this.process([data]) or specific filter logic to get processed buffers.
  3. Apply Rotation (sine wave gains) OR Vibrato (LFO/Hermite) as requested.
  4. Pass the processed buffer to callback(null, processedBuffer) or return it.

Triggers

  • implement native audio filters
  • fix rotation filter buffer
  • implement vibrato filter in javascript
  • stereo panning implementation
  • hermite interpolation vibrato implementation

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.