forked from AudioKit/AudioKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAKWaveTableTests.swift
149 lines (127 loc) · 3.65 KB
/
AKWaveTableTests.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//
// AKWaveTableTests.swift
// AudioKitTestSuite
//
// Created by Jeff Cooper and Aurelius Prochazka, revision history on Githbub.
// Copyright © 2018 AudioKit. All rights reserved.
//
import AudioKit
import XCTest
class AKWaveTableTests: AKTestCase {
var sampler: AKWaveTable?
func testDefault() {
afterStart = {
self.sampler?.play()
}
AKTestMD5("72ff03c8f6b529625877f89f4c7325bf")
}
func testReversePlayback() {
sampler?.startPoint = sampler!.size
sampler?.endPoint = 0
afterStart = {
self.sampler?.play()
}
AKTestMD5("4ff8bf4506289ce8b4f5f26f6d3c77ac")
}
let startOffsetMD5 = "d06ca74db9d9e5ca6892a5c6b32b978c"
func testStartOffset() {
afterStart = {
self.sampler?.play(from: 2_000)
}
AKTestMD5(startOffsetMD5)
}
func testStartOffsetUsingPoints() {
sampler?.startPoint = 2_000
afterStart = {
self.sampler?.play()
}
AKTestMD5(startOffsetMD5)
}
let endOffsetMD5 = "4fead31c7eb9c03698e8b94e286aa7ac"
func testEndOffset() {
afterStart = {
self.sampler?.play(from: 0, to: 300)
}
AKTestMD5(endOffsetMD5)
}
func testEndOffsetUsingSamplePoints() {
sampler?.startPoint = 0
sampler?.endPoint = 300
afterStart = {
self.sampler?.play()
}
AKTestMD5(endOffsetMD5)
}
let subsectionMD5 = "8ab03caca1d5011f73ad6e974ca6a9db"
func testSampleSubsection() {
afterStart = {
self.sampler?.play(from: 300, to: 600)
}
AKTestMD5(subsectionMD5)
}
func testSampleSubsectionUsingSamplePoints() {
sampler?.startPoint = 300
sampler?.endPoint = 600
afterStart = {
self.sampler?.play()
}
AKTestMD5(subsectionMD5)
}
let subsectionResetMD5 = "aea154e169b0f37557c5d8f5a3380315"
func testSampleSubsectionWithReset() {
sampler?.completionHandler = {
self.sampler?.play()
}
afterStart = {
self.sampler?.play(from: 300, to: 600)
}
AKTestMD5(subsectionResetMD5)
}
func testSampleSubsectionWithResetUsingSamplePoints() {
sampler?.completionHandler = {
self.sampler?.startPoint = 0
self.sampler?.endPoint = self.sampler!.size
self.sampler?.play()
}
afterStart = {
self.sampler?.startPoint = 300
self.sampler?.endPoint = 600
self.sampler?.play()
}
AKTestMD5(subsectionResetMD5)
}
func testForwardLoop() {
sampler?.loopStartPoint = 100
sampler?.loopEndPoint = 300
sampler?.endPoint = 300
sampler?.loopEnabled = true
afterStart = {
self.sampler?.play()
}
AKTestMD5("664e78be6d2d3a3daef538f981e20ecd")
}
func testReverseLoop() {
sampler?.loopStartPoint = 300
sampler?.loopEndPoint = 100
sampler?.endPoint = 300
sampler?.loopEnabled = true
afterStart = {
self.sampler?.play()
}
AKTestMD5("d8f001556a3efed4577101c2249b986c")
}
func setupSampler() {
if let path = Bundle.main.path(forResource: "sinechirp", ofType: "wav") {
let url = URL(fileURLWithPath: path)
let file = try! AKAudioFile(forReading: url)
sampler = AKWaveTable(file: file)
output = sampler
} else {
XCTFail("Could not load sinechirp.wav")
}
}
override func setUp() {
super.setUp()
setupSampler()
}
}