Using insert data to adjust volume (beads)

I am trying to inset a table and use the data to adjust the volume in gains
But I don’t know how to do it since they are in different methods but if i put them together, there will be an error

also, i’m using the library, beads

import beads.*;
import java.util.Arrays;

Table windDirection;
Table windSpeed;
int index = 0;
float y;

float speed_y;
int speedIndex = 0;

AudioContext ac;

void setup(){
size(800, 800);

windSpeed = loadTable(“”, “csv”);

ac = new AudioContext();
selectInput(“Select an audio file:”, “fileSelected”);



void getSpeedData() {
if (speedIndex < windSpeed.getRowCount()) {
// read the 2nd column (the 1), and read the row based on index which increments each draw()
speed_y = windSpeed.getInt(speedIndex, 1); // index is the row, 1 is the column with the data.
else {
speedIndex = 0;

//wind sound setting
void fileSelected(File selection) {

//Choose audio file
String audioFileName = selection.getAbsolutePath();
//Creates a sample player and loads in the Sample.
SamplePlayer player = new SamplePlayer(ac, SampleManager.sample(audioFileName));

//Modify the gain of a multi-channel audio signal
//Parameters: AudioContext, #inputs = #outputs, gain level( 0: silence)
Gain g = new Gain(ac, 2, );


void draw(){


if you could post your code it would help to try it out without having to retype it. sorry im lazy !

all good, sorry for that. I have upload the code and thanks


first of all, the obvious mistake would the missing parameter in:

Gain g = new Gain(ac, 2, );

apparently that class expects 3 values not two.
assuming that this is where you wanted to use speed_y I put it in.
maybe that is it ? code runs, but it seems the link to your data is refused.
when I try with a browser I get some warning that this website is not safe. probable ignorable but that may be the reason why the sketch does not continue at this point.

but that would be the next step…

yes, the empty parameter is to put speed_y

When I selected an audio, it remains silence

what’s the value range ? from the examples of the library it looks the use values in the rand of 0.1 to 1 (I figure zero to 100% volume (?)
your dataset has values about 2020-09-21 16:32:37,4 -> between 0 and 10 maybe

does it work if you put a fixed number like 0.3 for you ?

the value range is 0 - 16
I tried to divide it but doesn’t help

If I put a number there, it works

ok, i also notice:

that your data is a csv, but in the dataset you only have the comma in strange places

2020-09-19 17:37:36,4 2020-09-19 17:42:36,3 2020-09-19 17:47:36,6 ->

that would separate into:
2020-09-19 17:37:36
4 2020-09-19 17:42:36
3 2020-09-19 17:47:36
6 2020-09-19 17:52:36

so if I am not mistaken you say: take the first entry (which is 2020-09-19 17:37:36) and put it into speed_y

but before that, you never execute getSpeedData() ! :smiley:
so it stays 0 of course

but I can’t do anything to alter the dataset, right?

you could…
i didnt look into it in detail, but you can choose your separators differently and split the resulting entries again
String [] one -> split String with " " -> [2020-09-19] [17:37:36,4] [2020-09-19] [17:42:36,3] …
String [] two -> split every other entry with “,” -> [17:37:36] [4] [17:42:36] [3]
IntList -> append ever other entry
(basically by: for (int i=1,i<two.length; i+=2) so you take the 1,3,5th item)

or you could look for the index of the comma in a string and take the next character…

  1. find the first occurrence of a “,” in your string with indexOf()
  2. get the value you need with charAt() - which is the index you just got +1
  3. append it to an IntList
  4. cut the “used” part away from the string with substring() from index 0 to the index of the value
  5. repeat until your string is empty

thank you for helping