Skip to content

Code error on SimplePlayback example #108

Description

@todocono

As stated at Processing forum, there is a bug that prevents the amp() to function correctly.

This code works well both on PC and Mac (as coded by user GLV):

import processing.sound.*;

SoundFile soundfile;

void setup() {
  size(120, 360);
  background(255);

  // Load a soundfile
  soundfile = new SoundFile(this, "vibraphon.aiff");

  // Play the file in a loop
  soundfile.loop();
  
  mouseY = height/2; // Set initial value before using mouse in sketch window
}      

void draw() {
  background(255);
  
  // Map mouseY from 0.0 to 1.0 for amplitude
  //float amplitude = map(mouseY, 0, width, 0.0, 1.0);
  float amplitude = map(mouseY, 0, height, 0.0, 1.0); //< Corrected to height!
  
  println(mouseY, amplitude);
  
  circle(width/2, mouseY, 20);
  
  soundfile.amp(amplitude);
}

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions