forked from AudioKit/AudioKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAKMorphingOscillatorBankTests.swift
93 lines (78 loc) · 3.01 KB
/
AKMorphingOscillatorBankTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// AKMorphingOscillatorBankTests.swift
// AudioKitTestSuite
//
// Created by Aurelius Prochazka, revision history on GitHub.
// Copyright © 2018 AudioKit. All rights reserved.
//
import AudioKit
import XCTest
class AKMorphingOscillatorBankTests: AKTestCase {
var inputBank: AKMorphingOscillatorBank!
let waveforms = [AKTable(.sawtooth), AKTable(.sine), AKTable(.square), AKTable(.triangle)]
override func setUp() {
super.setUp()
// Need to have a longer test duration to allow for envelope to progress
duration = 1.0
afterStart = {
self.inputBank.play(noteNumber: 60, velocity: 120)
self.inputBank.play(noteNumber: 64, velocity: 110)
self.inputBank.play(noteNumber: 67, velocity: 100)
}
}
func testAttackDuration() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms, attackDuration: 0.123)
output = inputBank
AKTestMD5("a8eb74936c30722e24e1687f9398f1e4")
}
func testDecayDuration() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms, decayDuration: 0.234)
output = inputBank
AKTestMD5("bfb5654f45aa822a3b37ade16d55f50b")
}
func testDefault() {
inputBank = AKMorphingOscillatorBank()
output = inputBank
AKTestMD5("317b739a51d21c1b87dbebee209e2b0e")
}
func testIndex() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms, index: 1.7)
output = inputBank
AKTestMD5("4cd9dfef4f3dc76944e9f9ce468b9c44")
}
// Known breakage on macOS
#if os(iOS)
func testParameters() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms,
index: 1.7,
attackDuration: 0.123,
decayDuration: 0.234,
sustainLevel: 0.345,
pitchBend: 1,
vibratoDepth: 1.1,
vibratoRate: 1.2)
output = inputBank
AKTestMD5("bd119378ec447cf498bac22b98815883")
}
#endif
func testPitchBend() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms, pitchBend: 1.1)
output = inputBank
AKTestMD5("443dcfc1aa9c96f50b3f4ad5e7721882")
}
func testSustainLevel() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms, sustainLevel: 0.345)
output = inputBank
AKTestMD5("8d23d71ec765ac2878ed986271149f34")
}
func testVibrato() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms, vibratoDepth: 1, vibratoRate: 10)
output = inputBank
AKTestMD5("0db1ef4572600682a40b441fcf151d50")
}
func testWaveformArray() {
inputBank = AKMorphingOscillatorBank(waveformArray: waveforms)
output = inputBank
AKTestMD5("4cd9dfef4f3dc76944e9f9ce468b9c44")
}
}