New to this and clueless


#1

OsciStudio Version: A6
Operating System: Win10
:mushroom:
hey im new to all of this, I know some basics about soundwaves and stuff like that, but i do have experience with coding. Anyways I tried following this video: How To Draw Mushrooms On An Oscilloscope With Sound
and ended up getting this far:

#include <AudioMath.h>

PHASOR (phas1);
PHASOR (phas2);

SLIDER (volx, 0..2);
SLIDER (voly, 0..2);
SLIDER (vertoffset, -10..10);

SLIDER (freqmulti, 0..20);


vec3 gen(float t){
    vec3 v;	

    //circle
    v.x = sin(t*2*pi)*volx;
    v.y = cos(t*2*pi)*voly;

    //sawtooth
    v.y = v.y+(phas1*freqmulti)+vertoffset;

    //shroom
    v.x = v.x*sin(phas1)*volx;
    return v;
}

i dont think my code at //sawtooth is great, but I have no clue what to do with //shroom code.
I know its wrong here. So that’s why I’m here :v


#2

hey!

Your code was almost working already :slight_smile:

I’ve taken the liberty to modify it a little bit. You don’t really need those two phasors.
The “t” that is passed in to the gen function is (roughly) the value of the main phasor at the top of the channel.

However, I did put a separate phasor for the motion.

SLIDER (volx, 0..1);
SLIDER (voly, 0..1);
SLIDER (vertoffset, -1..1);

SLIDER (freqmulti, 10..60);

PHASOR(movement); 

vec3 gen(float t){
    vec3 v;	

    //a "fast" circle
    v.x = sin(t*2*pi*freqmulti)*volx;
    v.y = cos(t*2*pi*freqmulti)*voly;

    //sawtooth
    v.y += t - 0.5 + vertoffset;

    //shroom
	if(t>=0.75){
		v.x *= sin(t*2*pi); // make the cap
	}
	else{
		v.x *= 0.1; // make the stem narrow
	}

	// make it move ... / make multiple... 
	// the "multiplied by t" at the end is not mentioned in the 
	// video, it holds the mushrooms together at the base
	// try removing it ^^
	v.x += 0.25*sin(movement*2*pi)*t; 
    return v;
}

The values I’m using are:

volx = 0.243
voly = 0.023
vertoffset = 0
freqmult=40
movement.freq = 49.7

#3

thanks, I made a few adjustments to yours, like changing v.y = cos(t2pifreqmulti)voly:
to
v.z = cos(t
2
pi*freqmulti)voly;
and adding v.z = sin(t2
pi); and v.z *= 0.15; into the if else statment. (also changed v.x *= 0.15;)

this way it can be both 3D, and cleaner sounding.