refactor: some file and object renaming
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
		
							parent
							
								
									4d60684b07
								
							
						
					
					
						commit
						75f3ce03b3
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -2,3 +2,4 @@ nimble.paths
 | 
			
		||||
*.so
 | 
			
		||||
*.dll
 | 
			
		||||
/.lv2/
 | 
			
		||||
*.code-workspace
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,11 @@ type
 | 
			
		||||
        map: ptr UridMap
 | 
			
		||||
        midi_urid: Urid
 | 
			
		||||
 | 
			
		||||
    MidiEvent = object
 | 
			
		||||
        size: uint32
 | 
			
		||||
        frames: int64
 | 
			
		||||
        data: ptr UncheckedArray[byte]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;
 | 
			
		||||
                 bundlePath: cstring; features: ptr UncheckedArray[ptr Lv2Feature]):
 | 
			
		||||
@ -3,6 +3,6 @@
 | 
			
		||||
 | 
			
		||||
<urn:nymph:examples:multimode-filter>
 | 
			
		||||
    a lv2:Plugin ;
 | 
			
		||||
    lv2:binary <libmultimode_filter.so> ;
 | 
			
		||||
    rdfs:seeAlso <multimode_filter.ttl> .
 | 
			
		||||
    lv2:binary <libmultimodefilter.so> ;
 | 
			
		||||
    rdfs:seeAlso <multimodefilter.ttl> .
 | 
			
		||||
 | 
			
		||||
@ -9,8 +9,8 @@
 | 
			
		||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 | 
			
		||||
@prefix units: <http://lv2plug.in/ns/extensions/units#> .
 | 
			
		||||
 | 
			
		||||
<urn:nymph:examples:multimode-filter>
 | 
			
		||||
    a lv2:Plugin, lv2:AmplifierPlugin , doap:Project ;
 | 
			
		||||
<urn:nymph:examples:multimodefilter>
 | 
			
		||||
    a lv2:Plugin , lv2:FilterPlugin , doap:Project ;
 | 
			
		||||
 | 
			
		||||
    lv2:optionalFeature lv2:hardRTCapable , bufs:boundedBlockLength , opts:options ;
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ import nymph
 | 
			
		||||
import paramsmooth
 | 
			
		||||
import svf
 | 
			
		||||
 | 
			
		||||
const PluginUri = "urn:nymph:examples:multimode-filter"
 | 
			
		||||
const PluginUri = "urn:nymph:examples:multimodefilter"
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
    SampleBuffer = UncheckedArray[cfloat]
 | 
			
		||||
@ -19,7 +19,7 @@ type
 | 
			
		||||
        cutoff: ptr cfloat
 | 
			
		||||
        q: ptr cfloat
 | 
			
		||||
        mode: ptr cfloat
 | 
			
		||||
        svf: FilterSV
 | 
			
		||||
        svf: SVFilter
 | 
			
		||||
        smoothCutoff: ParamSmooth
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,7 @@ proc instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;
 | 
			
		||||
                 Lv2Handle {.cdecl.} =
 | 
			
		||||
    try:
 | 
			
		||||
        let plug = createShared(SVFPlugin)
 | 
			
		||||
        plug.svf = initFilterSV(fmLowPass, sampleRate)
 | 
			
		||||
        plug.svf = initSVFilter(fmLowPass, sampleRate)
 | 
			
		||||
        plug.smoothCutoff = initParamSmooth(20.0, sampleRate)
 | 
			
		||||
        return cast[Lv2Handle](plug)
 | 
			
		||||
    except OutOfMemDefect:
 | 
			
		||||
@ -9,32 +9,32 @@ type
 | 
			
		||||
    FilterMode* = enum
 | 
			
		||||
        fmLowPass, fmHighPass, fmBandPass, fmBandReject
 | 
			
		||||
 | 
			
		||||
    FilterSV* = object
 | 
			
		||||
    SVFilter* = object
 | 
			
		||||
        mode: FilterMode
 | 
			
		||||
        cutoff, q, lowPass, hiPass, bandPass, bandReject, a, b, maxCutoff: float
 | 
			
		||||
        sampleRate: float64
 | 
			
		||||
        needs_update: bool
 | 
			
		||||
        needsUpdate: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc reset*(self: var FilterSV) =
 | 
			
		||||
proc reset*(self: var SVFilter) =
 | 
			
		||||
    self.lowPass = 0.0
 | 
			
		||||
    self.hiPass = 0.0
 | 
			
		||||
    self.bandPass = 0.0
 | 
			
		||||
    self.bandReject = 0.0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc initFilterSV*(mode: FilterMode = fmLowPass, sampleRate: float64 = 48_000.0): FilterSV =
 | 
			
		||||
proc initSVFilter*(mode: FilterMode = fmLowPass, sampleRate: float64 = 48_000.0): SVFilter =
 | 
			
		||||
    result.mode = mode
 | 
			
		||||
    result.sampleRate = sampleRate
 | 
			
		||||
    result.reset()
 | 
			
		||||
    result.a = 0.0
 | 
			
		||||
    result.b = 0.0
 | 
			
		||||
    result.maxCutoff = sampleRate / 6.0
 | 
			
		||||
    result.needs_update = true
 | 
			
		||||
    result.needsUpdate = true
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc calcCoef*(self: var FilterSV) =
 | 
			
		||||
    if self.needs_update:
 | 
			
		||||
proc calcCoef*(self: var SVFilter) =
 | 
			
		||||
    if self.needsUpdate:
 | 
			
		||||
        self.a = 2.0 * sin(PI * self.cutoff / self.sampleRate)
 | 
			
		||||
 | 
			
		||||
        if self.q > 0.0:
 | 
			
		||||
@ -42,36 +42,36 @@ proc calcCoef*(self: var FilterSV) =
 | 
			
		||||
        else:
 | 
			
		||||
            self.b = 0.0
 | 
			
		||||
 | 
			
		||||
        self.needs_update = false
 | 
			
		||||
        self.needsUpdate = false
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc setCutoff*(self: var FilterSV, cutoff: float) =
 | 
			
		||||
proc setCutoff*(self: var SVFilter, cutoff: float) =
 | 
			
		||||
    let fc = min(self.maxCutoff, cutoff)
 | 
			
		||||
 | 
			
		||||
    if fc != self.cutoff:
 | 
			
		||||
        self.cutoff = fc
 | 
			
		||||
        self.needs_update = true
 | 
			
		||||
        self.needsUpdate = true
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc setQ*(self: var FilterSV, q: float) =
 | 
			
		||||
proc setQ*(self: var SVFilter, q: float) =
 | 
			
		||||
    if q != self.q:
 | 
			
		||||
        self.q = q
 | 
			
		||||
        self.needs_update = true
 | 
			
		||||
        self.needsUpdate = true
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc setMode*(self: var FilterSV, mode: FilterMode) =
 | 
			
		||||
proc setMode*(self: var SVFilter, mode: FilterMode) =
 | 
			
		||||
    self.mode = mode
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc setSampleRate*(self: var FilterSV, sampleRate: float) =
 | 
			
		||||
proc setSampleRate*(self: var SVFilter, sampleRate: float) =
 | 
			
		||||
    if sampleRate != self.sampleRate:
 | 
			
		||||
        self.sampleRate = sampleRate
 | 
			
		||||
        self.needs_update = true
 | 
			
		||||
        self.needsUpdate = true
 | 
			
		||||
        self.reset()
 | 
			
		||||
        self.calcCoef()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
proc process*(self: var FilterSV, sample: float): float =
 | 
			
		||||
proc process*(self: var SVFilter, sample: float): float =
 | 
			
		||||
    self.lowPass += self.a * self.bandPass
 | 
			
		||||
    self.hiPass = sample - (self.lowPass + (self.b * self.bandPass))
 | 
			
		||||
    self.bandPass += self.a * self.hiPass
 | 
			
		||||
 | 
			
		||||
@ -25,8 +25,8 @@ type Example = tuple
 | 
			
		||||
 | 
			
		||||
const examples = to_table({
 | 
			
		||||
    "amp": "urn:nymph:examples:amp",
 | 
			
		||||
    "multimode_filter": "urn:nymph:examples:multimode-filter",
 | 
			
		||||
    "miditranspose": "urn:nymph:examples:miditranspose",
 | 
			
		||||
    "multimodefilter": "urn:nymph:examples:multimode-filter",
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -48,7 +48,7 @@ proc getExample(task_name: string): Example =
 | 
			
		||||
    result.name = changeFileExt(args[^1], "")
 | 
			
		||||
 | 
			
		||||
    let examplesDir = thisDir() / "examples"
 | 
			
		||||
    result.source = examplesDir / changeFileExt(result.name, "nim")
 | 
			
		||||
    result.source = examplesDir / result.name & "_plugin.nim"
 | 
			
		||||
 | 
			
		||||
    if not fileExists(result.source):
 | 
			
		||||
        quit(&"Example '{result.name}' not found.")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user