Browse Source

Merge

master
Pete Shadbolt 9 years ago
parent
commit
268f12b582
6 changed files with 234 additions and 102 deletions
  1. +19
    -1
      README
  2. +92
    -101
      delay.csd
  3. +53
    -0
      web/:q
  4. +2
    -0
      web/css.css
  5. +15
    -0
      web/index.html
  6. +53
    -0
      web/main.js

+ 19
- 1
README View File

@@ -1 +1,19 @@
m i l c h l o d e
TODO:
Two or three channels

Global Sliders:
- BPM
- Input gain
- Amount of input to send to delay line
- Feedback amount

Global Switches:
- OSC Master/Minion

Channel Sliders:
- Gain

Channel buttons:
- Clear
- Mute/unmute
- Pitch down

+ 92
- 101
delay.csd View File

@@ -1,101 +1,92 @@
main.csd
Pete Shadbolt.2014
Based on code by Iain McCurdy, 2006
ksmps MAY NEED TO BE LOW (AND kr THEREFORE HIGH) WHEN WORKING WITH SHORT DELAY TIMES DEFINED INITIALLY AT KRATE
TODO: implement octave down/up (like old delay pedal), key control, panic button
<CsoundSynthesizer>
<CsOptions>
-iadc -odac -dm0
</CsOptions>
<CsInstruments>
sr = 44100 ;Sample rate
ksmps = 4 ;Number of audio samples in each control cycle
nchnls = 2 ;Number of channels (2=stereo)
0dbfs = 1 ;Maximum amplitude
gkporttime = 0.3; portamento time
; FLTK GUI interface
FLcolor 200, 200, 255, 0, 0, 0
FLpanel "M I L C H L O D E", 500, 300, 0, 0, 0, 1
gkOnOff,ihOnOff FLbutton "Input On/Off", 1, 0, 22, 180, 25, 5, 5, 0, 1, 0, -1
; Sliders
gkdlt,ihdlt FLslider "Delay Time (sec)", .001, 5, 0, 23, -1, 490, 25, 5, 50
gkmix,ihmix FLslider "Dry/Wet Mix", 0, 1, 0, 23, -1, 490, 25, 5, 100
gkfeedamt,ihfeedamt FLslider "Feedback Ratio", -1, 1, 0, 23, -1, 490, 25, 5, 150
gkamp,ihamp FLslider "Output Amplitude Rescaling", 0, 1, 0, 23, -1, 490, 25, 5, 200
gkingain,ihingain FLslider "Input Gain", 0, 1, 0, 23, -1, 140, 20, 350, 5
ih FLbox "Keys: ", 1, 5, 14, 490, 20, 0, 250
; Set defaults
FLsetVal_i 1, ihOnOff
FLsetVal_i .5, ihingain
FLsetVal_i 4, ihdlt
FLsetVal_i 0.5, ihmix
FLsetVal_i 0.95, ihfeedamt
FLsetVal_i .7, ihamp
FLpanel_end ;End of GUI
FLrun ;Run the FLTK thread
; Instr 1 is the source
instr 1
; Turn off with the switch
if gkOnOff=0 then
turnoff
endif
; Get input from mic/line
asigL, asigR ins
gasigL = asigL * gkingain
gasigR = asigR * gkingain
endin
; Instr 2 is the delay line
instr 2
; Sense keyboard
kKey FLkeyIn
kChanged changed kKey
printk2 kKey
;if kKey=112 && kChanged=1 then
;printf_i "awd"
;FLsetVal_i 0.0, gkfeedamt
;endif
kporttime linseg 0, .001, 1, 1, 1 ;A short envelope
kporttime = kporttime * gkporttime ;TODO: remove this
kdlt portk gkdlt, kporttime ;Apply portamento
adlt interp kdlt ;Interpolate
;Left channel
abufferL delayr 5 ;Buffer
adelsigL deltap3 adlt ;Tap
delayw gasigL + (adelsigL * gkfeedamt) ;Feedback
;Right channel
abufferR delayr 5 ;Buffer
adelsigR deltap3 adlt ;Tap
delayw gasigR + (adelsigR * gkfeedamt) ;Feedback
aL ntrpol gasigL, adelsigL, gkmix
aR ntrpol gasigR, adelsigR, gkmix
outs aL * gkamp, aR * gkamp ;Mix wet/dry
clear gasigL, gasigR ;Clear global audio sends
endin
</CsInstruments>
<CsScore>
i 2 0 -1 ;Instrument 2 plays a held note
f 0 3600 ;Keep performance going
</CsScore>
</CsoundSynthesizer>
<CsoundSynthesizer>
<CsOptions>
-iadc -odac -dm0
</CsOptions>

<CsInstruments>
; CSound parameters
sr = 44100 ; Sample rate
ksmps = 20 ; Number of audio samples in each control cycle
nchnls = 2 ; Number of channels (2=stereo)
0dbfs = 1 ; Maximum amplitude

; Delay parameters
gkporttime init 0.3 ; Portamento time
;gkdlt init 5 ; Max delay
;gkmix init .5 ; Dry/wet
;gkfeedamt init .95 ; Feedback ratio
;gkamp init .7 ; Output amplitude rescaling
;gkingain init .5 ; Input gain
;gkOnOff init 1 ; Input on off

; FLTK GUI interface
FLcolor 200, 200, 255, 0, 0, 0
FLpanel "M I L C H L O D E", 500, 300, 0, 0, 0, 1
gkOnOff,ihOnOff FLbutton "Input On/Off", 1, 0, 22, 180, 25, 5, 5, 0, 1, 0, -1

; Sliders
gkdlt,ihdlt FLslider "Delay Time (sec)", .001, 5, 0, 23, -1, 490, 25, 5, 50
gkmix,ihmix FLslider "Dry/Wet Mix", 0, 1, 0, 23, -1, 490, 25, 5, 100
gkfeedamt,ihfeedamt FLslider "Feedback Ratio", 0, 1, 0, 23, -1, 490, 25, 5, 150
gkamp,ihamp FLslider "Output Amplitude Rescaling", 0, 1, 0, 23, -1, 490, 25, 5, 200
gkingain,ihingain FLslider "Input Gain", 0, 1, 0, 23, -1, 140, 20, 350, 5
ih FLbox "Keys: ", 1, 5, 14, 490, 20, 0, 250

; Set defaults
FLsetVal_i 1, ihOnOff
FLsetVal_i .5, ihingain
FLsetVal_i 4, ihdlt
FLsetVal_i 0.5, ihmix
FLsetVal_i 0.95, ihfeedamt
FLsetVal_i .7, ihamp

FLpanel_end ;End of GUI
FLrun ;Run the FLTK thread

; Instr 1 is the source
instr 1

; Turn off with the switch
if gkOnOff=0 then
turnoff
endif

; Get input from mic/line
asigL, asigR ins
gasigL = asigL * gkingain
gasigR = asigR * gkingain
endin

; Instr 2 is the delay line
instr 2

kporttime linseg 0, .001, 1, 1, 1 ; A short envelope
kporttime = kporttime * gkporttime ; TODO: remove this
kdlt portk gkdlt, kporttime ; Apply portamento
adlt interp kdlt ; Interpolate

;Left channel
abufferL delayr 5 ;Buffer
adelsigL deltap3 adlt ;Tap
delayw gasigL + (adelsigL * gkfeedamt) ;Feedback

;Right channel
abufferR delayr 5 ;Buffer
adelsigR deltap3 adlt ;Tap
delayw gasigR + (adelsigR * gkfeedamt) ;Feedback

aL ntrpol gasigL, adelsigL, gkmix
aR ntrpol gasigR, adelsigR, gkmix

outs aL * gkamp, aR * gkamp ; Mix wet/dry
clear gasigL, gasigR ; Clear global audio sends
endin

</CsInstruments>

<CsScore>
i 2 0 -1 ;Instrument 2 plays a held note
f 0 3600 ;Keep performance going
</CsScore>

</CsoundSynthesizer>

+ 53
- 0
web/:q View File

@@ -0,0 +1,53 @@
var context = null;

// success callback when requesting audio input stream
function gotStream(stream) {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var ctx = new AudioContext();

// Create an AudioNode from the stream.
var micSource = ctx.createMediaStreamSource(stream);

// Connect it to the destination to hear yourself (or any other node for processing!)
micSource.connect(ctx.destination);

}

document.addEventListener('DOMContentLoaded', function() {

//if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia)
//navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

if (!navigator.getUserMedia) navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = { "audio": { "mandatory": { "googEchoCancellation": "false", "googAutoGainControl": "false", "googNoiseSuppression": "false", "googHighpassFilter": "false" }}}
navigator.getUserMedia(constraints, gotStream, function(e) { alert('Error getting audio'); console.log(e); });

//var controls = $("div#sliders");

//controls.find("input[name='delayTime']").on('input', function() {
//delay.delayTime.value = $(this).val();
//});

//controls.find("input[name='feedback']").on('input', function() {
//feedback.gain.value = $(this).val();
//});

//controls.find("input[name='frequency']").on('input', function() {
//filter.frequency.value = $(this).val();
//});

//delay = ctx.createDelay();
//delay.delayTime.value = 0.5;
//feedback = ctx.createGain();
//feedback.gain.value = 0.8;
//filter = ctx.createBiquadFilter();
//filter.frequency.value = 1000;
//delay.connect(feedback);
//feedback.connect(filter);
//filter.connect(delay);
//source.connect(delay);
//source.connect(ctx.destination);
//delay.connect(ctx.destination);

});


+ 2
- 0
web/css.css View File

@@ -0,0 +1,2 @@
body {font-family: monospace; font-size:12pt; background:url(rules.png) center center no-repeat;}
.player { color:white; background-color:black; width:200px; padding:5px; border-radius:5px; text-align:center; height:300px;}

+ 15
- 0
web/index.html View File

@@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Web audio test</title>
<link rel="stylesheet" type="text/css" href="css.css">
<script type="text/javascript" src="main.js"></script>
</head>

<body>

Testing testing

</body>
</html>


+ 53
- 0
web/main.js View File

@@ -0,0 +1,53 @@
var context = null;

// success callback when requesting audio input stream
function gotStream(stream) {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var ctx = new AudioContext();

// Create an AudioNode from the stream.
var micSource = ctx.createMediaStreamSource(stream);

// Connect it to the destination to hear yourself (or any other node for processing!)
micSource.connect(ctx.destination);

}

document.addEventListener('DOMContentLoaded', function() {

//if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia)
//navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

if (!navigator.getUserMedia) navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = { "audio": { "mandatory": { "googEchoCancellation": "false", "googAutoGainControl": "false", "googNoiseSuppression": "false", "googHighpassFilter": "false" }}}
navigator.getUserMedia(constraints, gotStream, function(e) { alert('Error getting audio'); console.log(e); });

//var controls = $("div#sliders");

//controls.find("input[name='delayTime']").on('input', function() {
//delay.delayTime.value = $(this).val();
//});

//controls.find("input[name='feedback']").on('input', function() {
//feedback.gain.value = $(this).val();
//});

//controls.find("input[name='frequency']").on('input', function() {
//filter.frequency.value = $(this).val();
//});

//delay = ctx.createDelay();
//delay.delayTime.value = 0.5;
//feedback = ctx.createGain();
//feedback.gain.value = 0.8;
//filter = ctx.createBiquadFilter();
//filter.frequency.value = 1000;
//delay.connect(feedback);
//feedback.connect(filter);
//filter.connect(delay);
//source.connect(delay);
//source.connect(ctx.destination);
//delay.connect(ctx.destination);

});


Loading…
Cancel
Save