Skip to content

Commit

Permalink
swift formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aure committed Aug 19, 2022
1 parent 3dfb80b commit 3c3ae0f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
29 changes: 17 additions & 12 deletions Sources/DevoloopAudioKit/DynaRageCompressor.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Copyright AudioKit. All Rights Reserved.

import AVFoundation
import AudioKit
import AudioKitEX
import AVFoundation
import CAudioKitEX

/// DynaRage Tube Compressor | Based on DynaRage Tube Compressor RE for Reason
/// by Devoloop Srls
///
public class DynaRageCompressor: Node {

let input: Node

/// Connected nodes
public var connections: [Node] { [input] }

/// Underlying AVAudioNode
public var avAudioNode = instantiate(effect: "dyrc")

// MARK: - Parameters

/// Specification details for ratio
Expand All @@ -27,7 +26,8 @@ public class DynaRageCompressor: Node {
address: akGetParameterAddress("DynaRageCompressorParameterRatio"),
defaultValue: 1,
range: 1.0 ... 20.0,
unit: .generic)
unit: .generic
)

/// Ratio to compress with, a value > 1 will compress
@Parameter(ratioDef) public var ratio: AUValue
Expand All @@ -39,7 +39,8 @@ public class DynaRageCompressor: Node {
address: akGetParameterAddress("DynaRageCompressorParameterThreshold"),
defaultValue: 0.0,
range: -100.0 ... 0.0,
unit: .decibels)
unit: .decibels
)

/// Threshold (in dB) 0 = max
@Parameter(thresholdDef) public var threshold: AUValue
Expand All @@ -51,7 +52,8 @@ public class DynaRageCompressor: Node {
address: akGetParameterAddress("DynaRageCompressorParameterAttackDuration"),
defaultValue: 0.1,
range: 0.1 ... 500.0,
unit: .seconds)
unit: .seconds
)

/// Attack dration
@Parameter(attackDurationDef) public var attackDuration: AUValue
Expand All @@ -63,7 +65,8 @@ public class DynaRageCompressor: Node {
address: akGetParameterAddress("DynaRageCompressorParameterReleaseDuration"),
defaultValue: 0.1,
range: 1.0 ... 20.0,
unit: .seconds)
unit: .seconds
)

/// Release duration
@Parameter(releaseDurationDef) public var releaseDuration: AUValue
Expand All @@ -75,7 +78,8 @@ public class DynaRageCompressor: Node {
address: akGetParameterAddress("DynaRageCompressorParameterRage"),
defaultValue: 0.1,
range: 0.1 ... 20.0,
unit: .generic)
unit: .generic
)

/// Rage Amount
@Parameter(rageDef) public var rage: AUValue
Expand All @@ -87,7 +91,8 @@ public class DynaRageCompressor: Node {
address: akGetParameterAddress("DynaRageCompressorParameterRageEnabled"),
defaultValue: 1.0,
range: 0.0 ... 1.0,
unit: .boolean)
unit: .boolean
)

/// Rage ON/OFF Switch
@Parameter(rageEnabledDef) public var rageEnabled: Bool
Expand All @@ -113,9 +118,9 @@ public class DynaRageCompressor: Node {
rageEnabled: Bool = rageEnabledDef.defaultValue == 1.0
) {
self.input = input

setupParameters()

self.ratio = ratio
self.threshold = threshold
self.attackDuration = attackDuration
Expand Down
27 changes: 16 additions & 11 deletions Sources/DevoloopAudioKit/RhinoGuitarProcessor.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright AudioKit. All Rights Reserved.

import AVFoundation
import AudioKit
import AudioKitEX
import AVFoundation
import CAudioKitEX

/// Guitar head and cab simulator.
///
public class RhinoGuitarProcessor: Node {

let input: Node

/// Connected nodes
public var connections: [Node] { [input] }

Expand All @@ -26,7 +25,8 @@ public class RhinoGuitarProcessor: Node {
address: akGetParameterAddress("RhinoGuitarProcessorParameterPreGain"),
defaultValue: 5.0,
range: 0.0 ... 10.0,
unit: .generic)
unit: .generic
)

/// Gain applied before processing.
@Parameter(preGainDef) public var preGain: AUValue
Expand All @@ -38,7 +38,8 @@ public class RhinoGuitarProcessor: Node {
address: akGetParameterAddress("RhinoGuitarProcessorParameterPostGain"),
defaultValue: 0.7,
range: 0.0 ... 1.0,
unit: .linearGain)
unit: .linearGain
)

/// Gain applied after processing.
@Parameter(postGainDef) public var postGain: AUValue
Expand All @@ -50,7 +51,8 @@ public class RhinoGuitarProcessor: Node {
address: akGetParameterAddress("RhinoGuitarProcessorParameterLowGain"),
defaultValue: 0.0,
range: -1.0 ... 1.0,
unit: .generic)
unit: .generic
)

/// Amount of Low frequencies.
@Parameter(lowGainDef) public var lowGain: AUValue
Expand All @@ -62,7 +64,8 @@ public class RhinoGuitarProcessor: Node {
address: akGetParameterAddress("RhinoGuitarProcessorParameterMidGain"),
defaultValue: 0.0,
range: -1.0 ... 1.0,
unit: .generic)
unit: .generic
)

/// Amount of Middle frequencies.
@Parameter(midGainDef) public var midGain: AUValue
Expand All @@ -74,7 +77,8 @@ public class RhinoGuitarProcessor: Node {
address: akGetParameterAddress("RhinoGuitarProcessorParameterHighGain"),
defaultValue: 0.0,
range: -1.0 ... 1.0,
unit: .generic)
unit: .generic
)

/// Amount of High frequencies.
@Parameter(highGainDef) public var highGain: AUValue
Expand All @@ -86,11 +90,12 @@ public class RhinoGuitarProcessor: Node {
address: akGetParameterAddress("RhinoGuitarProcessorParameterDistortion"),
defaultValue: 1.0,
range: 1.0 ... 20.0,
unit: .generic)
unit: .generic
)

/// Distortion Amount
@Parameter(distortionDef) public var distortion: AUValue

// MARK: - Initialization

/// Initialize this Rhino head and cab simulator node
Expand All @@ -114,7 +119,7 @@ public class RhinoGuitarProcessor: Node {
distortion: AUValue = distortionDef.defaultValue
) {
self.input = input

setupParameters()

self.preGain = preGain
Expand Down
12 changes: 4 additions & 8 deletions Tests/DevoloopAudioKitTests/GenericNodeTests.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
// Copyright AudioKit. All Rights Reserved.

import AudioKit
import DevoloopAudioKit
import AVFoundation
import DevoloopAudioKit
import XCTest

class GenericNodeTests: XCTestCase {

func nodeParameterTest(md5: String, factory: (Node)->Node, m1MD5: String = "", audition: Bool = false) {

func nodeParameterTest(md5: String, factory: (Node) -> Node, m1MD5: String = "", audition: Bool = false) {
let url = Bundle.module.url(forResource: "12345", withExtension: "wav", subdirectory: "TestResources")!
let player = AudioPlayer(url: url)!
let node = factory(player)

let duration = node.parameters.count + 1

let engine = AudioEngine()
var bigBuffer: AVAudioPCMBuffer? = nil
var bigBuffer: AVAudioPCMBuffer?

engine.output = node

Expand All @@ -32,7 +30,6 @@ class GenericNodeTests: XCTestCase {
}

for i in 0 ..< node.parameters.count {

let node = factory(player)
engine.output = node

Expand All @@ -47,13 +44,12 @@ class GenericNodeTests: XCTestCase {
audio.append(engine.render(duration: 1.0))

bigBuffer?.append(audio)

}

XCTAssertFalse(bigBuffer!.isSilent)

if audition { bigBuffer!.audition() }

XCTAssertTrue([md5, m1MD5].contains(bigBuffer!.md5), "\(node)\nFAILEDMD5 \(bigBuffer!.md5)")
}

Expand Down

0 comments on commit 3c3ae0f

Please sign in to comment.