I mixed up couple sketches to learn more about tabs in controlP5. In this example I need to put text to second tab, but line 40 gives me an error. what wrong I am doing ?
I' have processing application which use serial port to communicate with arduino, it's works fine unless, I want to use it on another pc. I found a problem, that different computers, have different numbers of com ports, and I must specify a com port in my code, so I must to recompile processing application each time I change a computer. Maybe somebody know how automatically do that, without recompiling processing sketch each time ?
I want be able to control echo effect with toggle controller, so I created method echo and after that used controlEvent method, but none of these technique worked for me, I guess I need some kind of setter, but don't know which one, maybe somebody know how to turn off/on echo effect with toggle ?
thanks for help
import controlP5.*;
import beads.*;
ControlP5 cp5;
AudioContext ac;
WavePlayer wp;
Gain g;
Glide gainGlide;
Glide frequencyGlide;
TapIn delayIn;
TapOut delayOut;
Gain delayGain;
void setup()
{
size(400, 300);
cp5 = new ControlP5(this);
cp5.addToggle("echo")
.setPosition(40, 250)
.setSize(50, 20)
.setValue(true)
.setMode(ControlP5.SWITCH)
;
ac = new AudioContext();
gainGlide = new Glide(ac, 0.0, 50);
frequencyGlide = new Glide(ac, 20, 50);
wp = new WavePlayer(ac, frequencyGlide, Buffer.SINE);
how to change this code that if I press radiobutton "A", code in 21-22 lines would be executed, if I press "B" nothing happen, if I press "C", code in 25'th line would be activated. I know it's noob question, but I am really new in programming.
thank you for help.
import controlP5.*;
ControlP5 p5;
RadioButton p;
void setup() {
size(400, 300);
p5 = new ControlP5(this);
p = p5.addRadioButton("option")
.setPosition(80, 100)
.addItem("A", 1)
.addItem("B", 2)
.addItem("C", 3)
.activate("A")
;
Toggle t = p.getItem("A");
// if pressed "A" execute this line if presed "B", do not execute this line
I am trying to make a virtual theremin with beads, to make it sound like a real deal I applied tremolo effect like in code below, but if I try to change sound pitch quickly it begin generating an awful sound, you clearly can hear that in example below, just try to move mouse cursor fast as possible up an down. So my question is, what to do, to be able to change sound pitch quickly and smoothly and still get decent tremolo effect
thank in advance :)
// Frequency_Modulation_02.pde
import beads.*; //sound library
AudioContext ac; // create our AudioContext
// declare our unit generators
WavePlayer modulator;
Glide modulatorFrequency;
WavePlayer carrier;
Gain g;
void setup()
{
size(400, 300);
// initialize our AudioContext
ac = new AudioContext();
// create the modulator, this WavePlayer will control the frequency of the carrier
modulatorFrequency = new Glide(ac, 20, 30);
modulator = new WavePlayer(ac, 1, Buffer.SINE);
// this is a custom function
// custom functions are a bit like custom Unit Generators (custom Beads)
// but they only override the calculate function
Function frequencyModulation = new Function(modulator)
{
public float calculate() {
// return x[0], which is the original value of the modulator signal (a sine wave)
// multiplied by 200.0 to make the sine vary between -200 and 200
// the number 200 here is called the "Modulation Index"
// the higher the Modulation Index, the louder the sidebands
// then add mouseY, so that it varies from mouseY - 200 to mouseY + 200
return (x[0] * 50.0) + mouseY;
}
};
// create a second WavePlayer, control the frequency with the function created above
carrier = new WavePlayer(ac, frequencyModulation, Buffer.SINE);
g = new Gain(ac, 1, 0.5); // create a Gain object to make sure we don't peak
g.addInput(carrier); // connect the carrier to the Gain input
ac.out.addInput(g); // connect the Gain output to the AudioContext
Controlp5 have a lot great tutorials of how to put sliders, toggles etc. to separate tabs, but I cant find any explanation of how to put basic shapes to different tabs.
in example below I want put rectangle to "rectangle" tab and ellipse to "ellipse" tab.
I am using controlp5 library for my project to add tabs and sliders, but I confused, because it' not refreshing.
For instance if I move slider, it's previous value left on the screen. The code below it's just a part of my project code, but you clearly can see the problem.
I am trying get familiar with beads audio library. Now I applied echo effect to simple sine wave generator, but after that volume control does not work, how to fix that problem ?
thanks for answer
import beads.*;
AudioContext ac;
WavePlayer wp;
Gain g;
Glide gainGlide;
Glide frequencyGlide;
TapIn delayIn;
TapOut delayOut;
Gain delayGain;
void setup()
{
size(400, 300);
ac = new AudioContext();
gainGlide = new Glide(ac, 0.0, 50);
frequencyGlide = new Glide(ac, 20, 50);
wp = new WavePlayer(ac, frequencyGlide, Buffer.SINE);
Hello, I am new here. So I am working with my project and I need advice.
I want to make theremin music device useing 2 x HC-SR04 ultrasonic range finders, Arduino and Processing,
With one URF I will change sound frequince, with other volume.
At this stage of project I
successfully getting data from arduino to processing and I am generating sound, but I am not able to put data from serial port to to line where sound is generating, what I need to do ?
Simply I don't know how to send data from one class to onother, maybe someone can give me a link to good tutorial about this.