p5.Gain.amp() throws this.node.volume is undefined

Abierto
#128 1 comentario 0 reacciones 0 asignados Ver en GitHub

@leocb ya está trabajando en esto.

Desde el 29/10/2026.

  • #129 de @leocb — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript

Línea de trabajo

Start with the p5.Gain.amp() and SoundFile.setVolume() implementations and their tests, then trace how their output nodes are created for p5.js v2. Reproduce the reported errors with the linked sketch and check the volume APIs against the documented behavior. Done means both APIs adjust volume without throwing; an open pull request is already linked to this issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Example on this sketch: https://editor.p5js.org/leocb/sketches/qYCmn3F2x

Environment:

  • p5.js: 2.3.4 (CDN)
  • p5.sound: 0.4.1 (CDN: https://cdn.jsdelivr.net/npm/[email protected]/dist/p5.sound.min.js)
  • Browser: Firefox (latest, macOS)

Description:

When using p5.sound v0.4.1 with p5.js v2, the volume-control APIs appear to be broken or missing.

p5.Gain.amp() throws a TypeError:
Calling gain.amp(level) on a p5.Gain instance produces:
TypeError: can't access property "rampTo", this.node.volume is undefined
This suggests the internal node object created by the library (likely a Tone.js node, given that p5.sound is an abstraction over Tone.js) does not expose a volume property in this version. The amp() method seems to be trying to call rampTo on an undefined volume object.

Workaround:

Accessing the underlying Web Audio GainNode directly bypasses the broken high-level API and works correctly:

// For p5.SoundFile:
soundFile.output.gain.value = level;

// For p5.Gain:
gain.output.gain.value = level;

This confirms that the audio graph is correctly constructed and the output node is a valid GainNode, but the wrapper methods (amp and setVolume) are not functioning as expected in this version.

Expected behavior:

  • gain.amp(level) should adjust the gain node's volume without throwing an error, as described in the reference.
  • soundFile.setVolume(level) should exist and adjust the volume as documented.

Steps to reproduce:

  1. Load p5.js v2 and p5.sound v0.4.1.
  2. Create a p5.Gain and connect a SoundFile to it.
  3. Call gain.amp(0.5) in draw() → observe the rampTo error.
  4. Alternatively, call soundFile.setVolume(0.5) → observe the "not a function" error.
Lenguaje dominante
JavaScript
Estrellas
60
Forks
28
Merge medio
8 h 53 min
PR fusionados (30 d)
2

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de processing/p5.sound.js

Todos los issues de processing/p5.sound.js

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.