ԀI˥ℲOᙠᴚ∩⊥
🔍

LET’S GENERATE 8-BIT SOUNDS

ONLINE EDITOR VERSION

// check the editor >>> https://sfxr.me/

let alive = 0;
let xoff = 0;
let yoff = 0;

function setup() {
  createCanvas(200, 200);
  

}

function draw() {
  background(220);
  
  if(alive>.1){
  
    
    alive *= .96;
    
    xoff = sin( millis() *.1 ) * alive * 30;
    yoff = sin( millis() *.3 ) * alive * 30;
    
  }
  
  let px = width/2 + xoff;
  let py = height/2 + yoff;
  
  fill(0);
  noStroke();
  ellipse(px,py,111,111);
    
  
}

let attack = 0; // anstieg
let sustain = 0; // halten
let decay = 0; // abfall


function mousePressed(){
  
  alive = 1;

 
     sound['wave_type']= int(random()*2)+1;
  sound['p_base_freq']= random()*.4+.2;
  
   sound['p_freq_ramp']= random()*.8+.1;
  
  sound['p_vib_strength']=  random()*.7;
  sound['p_vib_speed']=  random()*1.1;
  
  sound['p_repeat_speed']=  random()*.9+.1;
  
  
  
  sound['p_env_attack']= random()*.3+.03;
  sound['p_env_sustain']= random()*.3+.1;
  sound['p_env_decay']= random()*.1+.4;
  sound['p_env_punch']= random()*.8+.1;
  
  
  
   sound['p_arp_speed']=  random()*.4+1.1;
  sound['p_arp_mod']=  random()*.4+.5;
  
  
 
  
  
  var s = new SoundEffect(sound).generate();
// returns a webaudio object if supported, or an Audio object
s.getAudio().play();

}


var sound = {
  "oldParams": true,
  "wave_type": 1,
  "p_env_attack": 0,
  "p_env_sustain": 0.31718502829007483,
  "p_env_punch": 0,
  "p_env_decay": 0.2718540993592685,
  "p_base_freq": 0.26126191208337196,
  "p_freq_limit": 0,
  "p_freq_ramp": 0.43787689856926615,
  "p_freq_dramp": 0,
  "p_vib_strength": 0,
  "p_vib_speed": 0,
  "p_arp_mod": 0,
  "p_arp_speed": 0,
  "p_duty": 1,
  "p_duty_ramp": 0,
  "p_repeat_speed": 0.7558565452384385,
  "p_pha_offset": 0,
  "p_pha_ramp": 0,
  "p_lpf_freq": 1,
  "p_lpf_ramp": 0,
  "p_lpf_resonance": 0,
  "p_hpf_freq": 0,
  "p_hpf_ramp": 0,
  "sound_vol": 0.25,
  "sample_rate": 44100,
  "sample_size": 8
};




<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

  </head>
  <body>
    
    

    <script src="https://sfxr.me/riffwave.js"></script>

    <script src="https://sfxr.me/sfxr.js"></script>

    
    <script src="sketch.js"></script>
  </body>
</html>

Related Posts
SPEAK WITH AN 8-BIT COMPUTER
SPEAK WITH AN 8-BIT COMPUTER

microphone input is observed to trigger random 8-bit sound

SPEECH IN : SPEECH OUT
SPEECH IN : SPEECH OUT

realtime speech recorgnisiton and speech synthesis in the browser

THE WANDERING BRUSH
THE WANDERING BRUSH

simple drawing machine introducing classes and objects

GAMEPAD BROWSER INPUT
GAMEPAD BROWSER INPUT

how to grab data input from Bluetooth gamepad to browser with JS