refactor: rename variable 'amp' -> 'plug'
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
parent
29c20cb8fc
commit
3f14ec790c
@ -28,28 +28,28 @@ type
|
|||||||
proc instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;
|
proc instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;
|
||||||
bundlePath: cstring; features: ptr UncheckedArray[ptr Lv2Feature]):
|
bundlePath: cstring; features: ptr UncheckedArray[ptr Lv2Feature]):
|
||||||
Lv2Handle {.cdecl.} =
|
Lv2Handle {.cdecl.} =
|
||||||
let amp: ptr MidiTransposePlugin = createShared(MidiTransposePlugin)
|
let plug: ptr MidiTransposePlugin = createShared(MidiTransposePlugin)
|
||||||
amp.map = cast[ptr UridMap](lv2FeaturesData(features, lv2UridMap))
|
plug.map = cast[ptr UridMap](lv2FeaturesData(features, lv2UridMap))
|
||||||
|
|
||||||
if amp.map.isNil:
|
if plug.map.isNil:
|
||||||
freeShared(amp)
|
freeShared(plug)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
amp.midi_urid = amp.map.map(amp.map.handle, lv2MidiMidiEvent)
|
plug.midi_urid = plug.map.map(plug.map.handle, lv2MidiMidiEvent)
|
||||||
|
|
||||||
return cast[Lv2Handle](amp)
|
return cast[Lv2Handle](plug)
|
||||||
|
|
||||||
|
|
||||||
proc connectPort(instance: Lv2Handle; port: cuint;
|
proc connectPort(instance: Lv2Handle; port: cuint;
|
||||||
dataLocation: pointer) {.cdecl.} =
|
dataLocation: pointer) {.cdecl.} =
|
||||||
let amp = cast[ptr MidiTransposePlugin](instance)
|
let plug = cast[ptr MidiTransposePlugin](instance)
|
||||||
case cast[PluginPort](port)
|
case cast[PluginPort](port)
|
||||||
of PluginPort.Input:
|
of PluginPort.Input:
|
||||||
amp.input = cast[ptr AtomSequence](dataLocation)
|
plug.input = cast[ptr AtomSequence](dataLocation)
|
||||||
of PluginPort.Output:
|
of PluginPort.Output:
|
||||||
amp.output = cast[ptr AtomSequence](dataLocation)
|
plug.output = cast[ptr AtomSequence](dataLocation)
|
||||||
of PluginPort.Transposition:
|
of PluginPort.Transposition:
|
||||||
amp.transposition = cast[ptr cfloat](dataLocation)
|
plug.transposition = cast[ptr cfloat](dataLocation)
|
||||||
|
|
||||||
|
|
||||||
proc activate(instance: Lv2Handle) {.cdecl.} =
|
proc activate(instance: Lv2Handle) {.cdecl.} =
|
||||||
@ -57,17 +57,17 @@ proc activate(instance: Lv2Handle) {.cdecl.} =
|
|||||||
|
|
||||||
|
|
||||||
proc run(instance: Lv2Handle; nSamples: cuint) {.cdecl.} =
|
proc run(instance: Lv2Handle; nSamples: cuint) {.cdecl.} =
|
||||||
let amp = cast[ptr MidiTransposePlugin](instance)
|
let plug = cast[ptr MidiTransposePlugin](instance)
|
||||||
let outCapacity = amp.output.atom.size
|
let outCapacity = plug.output.atom.size
|
||||||
atomSequenceClear(amp.output)
|
atomSequenceClear(plug.output)
|
||||||
amp.output.atom.type = amp.input.atom.type
|
plug.output.atom.type = plug.input.atom.type
|
||||||
|
|
||||||
if not atomSequenceIsEmpty(amp.input):
|
if not atomSequenceIsEmpty(plug.input):
|
||||||
#echo &"Event sequence size: {amp.input.atom.size}"
|
#echo &"Event sequence size: {plug.input.atom.size}"
|
||||||
let noteOffset = clamp(floor(amp.transposition[] + 0.5), -12, 12).uint8
|
let noteOffset = clamp(floor(plug.transposition[] + 0.5), -12, 12).uint8
|
||||||
|
|
||||||
for ev in amp.input:
|
for ev in plug.input:
|
||||||
if ev.body.`type` == amp.midi_urid:
|
if ev.body.`type` == plug.midi_urid:
|
||||||
var msg = cast[ptr UncheckedArray[uint8]](atomContents(AtomEvent, ev))
|
var msg = cast[ptr UncheckedArray[uint8]](atomContents(AtomEvent, ev))
|
||||||
#echo &"0x{toHex(msg[0], 2)} 0x{toHex(msg[1], 2)} 0x{toHex(msg[2], 2)}"
|
#echo &"0x{toHex(msg[0], 2)} 0x{toHex(msg[1], 2)} 0x{toHex(msg[2], 2)}"
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ proc run(instance: Lv2Handle; nSamples: cuint) {.cdecl.} =
|
|||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
discard atomSequenceAppendEvent(amp.output, outCapacity, ev)
|
discard atomSequenceAppendEvent(plug.output, outCapacity, ev)
|
||||||
|
|
||||||
|
|
||||||
proc deactivate(instance: Lv2Handle) {.cdecl.} =
|
proc deactivate(instance: Lv2Handle) {.cdecl.} =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user