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 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-label">
<label class="label">
@ -361,6 +338,29 @@
</label>
</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>

View File

@ -123,19 +123,22 @@ export class MIDI extends Input{
super(keyer)
this.ditDuration = 100
this.keyerMode = 0
this.midiAccess = {outputs: []} // stub while we wait for async stuff
if (navigator.requestMIDIAccess) {
this.midiInit()
}
}
async midiInit(access) {
this.inputs = []
this.midiAccess = await navigator.requestMIDIAccess()
this.midiAccess.addEventListener("statechange", e => this.midiStateChange(e))
this.midiStateChange()
}
// If you're looking for the thing that sets the tx tone,
// that's in outputs.mjs:SetMIDINote
sendState() {
for (let output of this.midiAccess.outputs.values()) {

View File

@ -44,23 +44,26 @@ class Noise extends AudioSource {
modulatorGain: new GainNode(context),
filter: WhiteNoise(context),
filterGain: new GainNode(context),
filterGainModulator: new OscillatorNode(context),
filterGainModulatorGain: new GainNode(context),
}
wn.modulator.frequency.value = 0
wn.modulatorGain.gain.value = 0
wn.filter.frequency.value = 800
wn.filterGain.gain.value = 0.8 / noises
wn.filterGainModulator.frequency.value = 1
wn.filterGainModulatorGain.gain.value = 1
wn.modulator.connect(wn.modulatorGain)
wn.modulatorGain.connect(wn.filter.frequency)
wn.filter.connect(wn.filterGain)
wn.filterGain.connect(this.masterGain)
wn.filter.connect(this.masterGain)
wn.modulator.start()
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.masterGain.gain.value = 0.5
}

View File

@ -423,7 +423,6 @@ class MIDIBuzzer extends Buzzer {
if (tx) {
return
}
this.sendAt(when, [0x90, this.note, 0x7f])
}
@ -443,9 +442,10 @@ class MIDIBuzzer extends Buzzer {
*/
SetMIDINote(tx, note) {
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(
"#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,
)
this.inputInit(