Adapter: actually change pitches

This commit is contained in:
Neale Pickett 2023-02-25 18:12:17 -07:00
parent 1c8ab50f0a
commit f8b5cf22af
5 changed files with 41 additions and 32 deletions

View File

@ -269,29 +269,6 @@
</div> </div>
</div> </div>
<div class="field is-horizontal">
<div class="field-label">
<label class="label">
<span data-i18n="label.gain">noise</span>:
<output for="noiseGain"></output>%
<i class="mdi mdi-volume-off muted"></i>
</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input
id="noiseGain"
type="range"
min="0"
max="100"
value="0"
step="1">
</div>
</div>
</div>
</div>
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="field-label"> <div class="field-label">
<label class="label"> <label class="label">
@ -361,6 +338,29 @@
</label> </label>
</p> </p>
<div class="field is-horizontal">
<div class="field-label">
<label class="label">
<span data-i18n="label.gain">noise</span>:
<output for="noiseGain"></output>%
<i class="mdi mdi-volume-off muted"></i>
</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input
id="noiseGain"
type="range"
min="0"
max="100"
value="0"
step="1">
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -137,6 +137,9 @@ export class MIDI extends Input{
this.midiStateChange() this.midiStateChange()
} }
// If you're looking for the thing that sets the tx tone,
// that's in outputs.mjs:SetMIDINote
sendState() { sendState() {
for (let output of this.midiAccess.outputs.values()) { for (let output of this.midiAccess.outputs.values()) {
// Turn off keyboard mode // Turn off keyboard mode

View File

@ -44,23 +44,26 @@ class Noise extends AudioSource {
modulatorGain: new GainNode(context), modulatorGain: new GainNode(context),
filter: WhiteNoise(context), filter: WhiteNoise(context),
filterGain: new GainNode(context), filterGain: new GainNode(context),
filterGainModulator: new OscillatorNode(context),
filterGainModulatorGain: new GainNode(context),
} }
wn.modulator.frequency.value = 0 wn.modulator.frequency.value = 0
wn.modulatorGain.gain.value = 0 wn.modulatorGain.gain.value = 0
wn.filter.frequency.value = 800 wn.filter.frequency.value = 800
wn.filterGain.gain.value = 0.8 / noises wn.filterGain.gain.value = 0.8 / noises
wn.filterGainModulator.frequency.value = 1
wn.filterGainModulatorGain.gain.value = 1
wn.modulator.connect(wn.modulatorGain) wn.modulator.connect(wn.modulatorGain)
wn.modulatorGain.connect(wn.filter.frequency) wn.modulatorGain.connect(wn.filter.frequency)
wn.filter.connect(wn.filterGain) wn.filter.connect(this.masterGain)
wn.filterGain.connect(this.masterGain)
wn.modulator.start() wn.modulator.start()
this.whiteNoise.push(wn) this.whiteNoise.push(wn)
} }
this.SetNoiseParams(0, 0.07, 70, 400, 0.4) this.SetNoiseParams(0, 0.07, 70, 400, 0.0)
this.SetNoiseParams(1, 0.03, 200, 1600, 0.4) this.SetNoiseParams(1, 0.03, 200, 1600, 0.4)
this.masterGain.gain.value = 0.5 this.masterGain.gain.value = 0.5
} }

View File

@ -423,7 +423,6 @@ class MIDIBuzzer extends Buzzer {
if (tx) { if (tx) {
return return
} }
this.sendAt(when, [0x90, this.note, 0x7f]) this.sendAt(when, [0x90, this.note, 0x7f])
} }
@ -443,9 +442,10 @@ class MIDIBuzzer extends Buzzer {
*/ */
SetMIDINote(tx, note) { SetMIDINote(tx, note) {
if (tx) { if (tx) {
return this.sendAt(0, [0xB0, 0x02, note])
} else {
this.note = note
} }
this.note = note
} }
} }

View File

@ -106,7 +106,10 @@ class VailClient {
} }
this.inputInit( this.inputInit(
"#rx-tone", "#rx-tone",
e => this.outputs.SetMIDINote(false, e.target.value), e => {
this.noise.SetNoiseFrequency(1, Music.MIDINoteFrequency(e.target.value))
this.outputs.SetMIDINote(false, e.target.value)
},
toneTransform, toneTransform,
) )
this.inputInit( this.inputInit(