# How to replace "noise" with "music"?

**URL:** https://discourse.processing.org/t/how-to-replace-noise-with-music/7001
**Category:** Libraries
**Created:** [December 29, 2018, 11:18pm UTC](https://discourse.processing.org/t/how-to-replace-noise-with-music/7001 "2018-12-29T23:18:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aewan](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aewan](https://discourse.processing.org/u/aewan)
#### Post date: [December 29, 2018, 11:18pm UTC](https://discourse.processing.org/t/how-to-replace-noise-with-music/7001/1 "2018-12-29T23:18:06Z")

</div>

Hi everyone!

I really love sketches like these two:

> **[Organic Landscape - OpenProcessing](https://www.openprocessing.org/sketch/76291)**
>
> Changing landscape =\\
> A simple noise function. better on openGL.

  

> **[Noisy landscape - OpenProcessing](https://www.openprocessing.org/sketch/153917)**
>
> explore this noisy landscape by moving the mouse around

They are based off the noise function in processing, but I would like to try and change them to work off music files.

Using Minim to play an audio file, I’ve tried swapping “noise” in the line to the output of an audio file, but can’t get the syntax to work- it keeps generating various errors. Here’s what I tried:  
Original-  
“vertex(x,y-i+ (noise(x\*.01, (frameCount\*.01), i\*.01 )_300))"  
My attempts-  
"vertex(x,y-i+ (player.left.get(x_.01, (frameCount\*.01), i\*.01 )_300))"  
"vertex(x,y-i+ (player.bufferSize(x_.01, (frameCount\*.01), i\*.01 )\*300))”

Does anyone know how I can do this, so that the sketch generates similar patterns based on an audio file rather than noise? Or is this simply not possible?

Here’s more of the code from that sketch:

void draw()  
{  
background(255);  
noFill();  
stroke(0,100);  
for(int i = 0; i \< 100; i+=1.5)  
{  
beginShape();  
vertex(0,height);  
for(int x = 0; x \< width; x+=5)  
{  
//noise always return a number between 0,1  
vertex(x,y-i+ (noise(x\*.01, (frameCount\*.01), i\*.01 )\*300));  
}  
vertex(width, height);  
endShape();  
}  
}

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [December 30, 2018, 12:02am UTC](https://discourse.processing.org/t/how-to-replace-noise-with-music/7001/2 "2018-12-30T00:02:11Z")

</div>

What errors are you getting?

Can you post what you’ve tried, in the form of a [MCVE](https://stackoverflow.com/help/mcve)?

---

<div class="post-metadata">

### Author: ![aewan](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aewan](https://discourse.processing.org/u/aewan)
#### Post date: [December 30, 2018, 6:17pm UTC](https://discourse.processing.org/t/how-to-replace-noise-with-music/7001/3 "2018-12-30T18:17:41Z")

</div>

Thanks for getting back Kevin.  
Here’s what I tried, with the errors that each variation produced.

import ddf.minim._;  
import ddf.minim.analysis._;

Minim minim;  
AudioPlayer player;

float y;

void setup()  
{  
size(1028,500);  
y = height/2;  
smooth();  
minim = new Minim(this);  
player = minim.loadFile(“MUSIC FILE.mp3”);  
player.play();  
}

void draw()  
{  
background(255);  
noFill();  
stroke(0,100);

for(int i = 0; i \< 100; i+=1.5)  
{  
beginShape();  
vertex(0,height);  
for(int x = 0; x \< width; x+=5)  
{  
//this line below produces the error “the function left(float, float, float) does not exist”-  
vertex(x,y-i+ (player.left(x\*.01, (frameCount\*.01), i\*.01 )_300));  
//this line below produces the error “Error on “)””-  
//vertex(x,y-i+ (player.bufferSize()(x_.01, (frameCount\*.01), i\*.01 )\*300));  
}  
vertex(width, height);  
endShape();  
}  
}
