# Using p5.distortion in p5.sound

**URL:** https://discourse.processing.org/t/using-p5-distortion-in-p5-sound/33777
**Category:** Libraries
**Created:** [November 26, 2021, 9:16pm UTC](https://discourse.processing.org/t/using-p5-distortion-in-p5-sound/33777 "2021-11-26T21:16:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![angeltapes](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@angeltapes](https://discourse.processing.org/u/angeltapes)
#### Post date: [November 26, 2021, 9:16pm UTC](https://discourse.processing.org/t/using-p5-distortion-in-p5-sound/33777/1 "2021-11-26T21:16:39Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

I’ve been trying to use the p5.distortion extension of p5.effect to distort an oscillator. I don’t think it’s working, however. Does anyone have an example of the correct format?

```auto
var sinOsc, distort;
		
function setup() {
	createCanvas(windowWidth, windowHeight);
	background(100);
	distort = new p5.Distortion();

	sinOsc = new p5.Oscillator('sine');
  sinOsc.amp(0);
	sinOsc.disconnect();
  sinOsc.connect(distort);
	sinOsc.start();
	
	distort.set(0.9)
}

function draw() {
	ellipse(mouseX, mouseY, 20, 20);
	sinOsc.freq(mouseX)
}

function touchMoved(){
sinOsc.amp(1)
}

function touchEnded(){
sinOsc.amp(0)
}

```
