Skip to content

Implement recording samples from AudioIn (and other sound sources) #55

Description

@dhowe

I'm trying to build a simple demo where you start recording with a keypress from AudioIn, then stop the recording, see the waveform of the recorded sound, and hear it playing. Seems like it should be trivial, but I don't find the needed methods... How to record a sample then play it?
thanks

AudioIn input;
Amplitude loudness;

void setup() {
  size(100, 400);
  noStroke();
  input = new AudioIn(this, 0);
  loudness = new Amplitude(this);
}

void keyPressed() {
  if (keyCode == 32) {     // start record
    loudness.input(input);  
  }
  if (keyCode == 10) {     // stop record

    input.stop();   // How to convert input to AudioSample ?
  }
}

void draw() {
  float f = loudness.analyze() * 5;
  background(125, 255, 125);
  rect(0, height, 100, -height * f);
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions