beats 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/README.markdown +28 -10
- data/bin/beats +9 -7
- data/lib/audioengine.rb +172 -0
- data/lib/audioutils.rb +73 -0
- data/lib/beats.rb +14 -15
- data/lib/beatswavefile.rb +17 -37
- data/lib/kit.rb +148 -71
- data/lib/pattern.rb +20 -117
- data/lib/patternexpander.rb +111 -0
- data/lib/song.rb +78 -132
- data/lib/songoptimizer.rb +29 -33
- data/lib/songparser.rb +70 -45
- data/lib/track.rb +11 -82
- data/test/audioengine_test.rb +261 -0
- data/test/audioutils_test.rb +45 -0
- data/test/fixtures/expected_output/example_split_mono_16-hh_closed.wav +0 -0
- data/test/{examples/split-agogo_high.wav → fixtures/expected_output/example_split_mono_16-hh_closed2.wav} +0 -0
- data/test/fixtures/expected_output/example_split_mono_8-hh_closed.wav +0 -0
- data/test/{examples/split-tom4.wav → fixtures/expected_output/example_split_mono_8-hh_closed2.wav} +0 -0
- data/test/fixtures/expected_output/example_split_stereo_16-hh_closed.wav +0 -0
- data/test/fixtures/expected_output/example_split_stereo_16-hh_closed2.wav +0 -0
- data/test/fixtures/expected_output/example_split_stereo_8-hh_closed.wav +0 -0
- data/test/fixtures/expected_output/example_split_stereo_8-hh_closed2.wav +0 -0
- data/test/fixtures/invalid/{bad_structure.txt → bad_flow.txt} +2 -2
- data/test/fixtures/invalid/bad_repeat_count.txt +1 -1
- data/test/fixtures/invalid/bad_rhythm.txt +1 -1
- data/test/fixtures/invalid/bad_tempo.txt +1 -1
- data/test/fixtures/invalid/{no_structure.txt → no_flow.txt} +1 -1
- data/test/fixtures/invalid/pattern_with_no_tracks.txt +1 -1
- data/test/fixtures/invalid/sound_in_kit_not_found.txt +1 -1
- data/test/fixtures/invalid/sound_in_kit_wrong_format.txt +10 -0
- data/test/fixtures/invalid/sound_in_track_not_found.txt +1 -1
- data/test/fixtures/invalid/sound_in_track_wrong_format.txt +8 -0
- data/test/fixtures/invalid/template.txt +1 -1
- data/test/fixtures/valid/example_mono_16.txt +5 -3
- data/test/fixtures/valid/example_mono_8.txt +5 -3
- data/test/fixtures/valid/example_no_kit.txt +1 -1
- data/test/fixtures/valid/example_stereo_16.txt +7 -4
- data/test/fixtures/valid/example_stereo_8.txt +5 -3
- data/test/fixtures/valid/example_with_empty_track.txt +1 -1
- data/test/fixtures/valid/example_with_kit.txt +1 -1
- data/test/fixtures/valid/multiple_tracks_same_sound.txt +33 -0
- data/test/fixtures/valid/no_tempo.txt +1 -1
- data/test/fixtures/valid/optimize_pattern_collision.txt +28 -0
- data/test/fixtures/valid/pattern_with_overflow.txt +1 -1
- data/test/fixtures/valid/repeats_not_specified.txt +2 -2
- data/test/fixtures/valid/with_structure.txt +10 -0
- data/test/fixtures/yaml/song_yaml.txt +5 -5
- data/test/includes.rb +4 -2
- data/test/integration.rb +3 -3
- data/test/kit_test.rb +136 -109
- data/test/pattern_test.rb +31 -131
- data/test/patternexpander_test.rb +142 -0
- data/test/song_test.rb +104 -102
- data/test/songoptimizer_test.rb +52 -38
- data/test/songparser_test.rb +79 -46
- data/test/sounds/composite_snare_mono_8_tom3_mono_16_mono_16.wav +0 -0
- data/test/sounds/composite_snare_mono_8_tom3_mono_8_mono_16.wav +0 -0
- data/test/sounds/composite_snare_stereo_16_tom3_mono_16_stereo_16.wav +0 -0
- data/test/sounds/composite_snare_stereo_8_tom3_mono_16_stereo_16.wav +0 -0
- data/test/track_test.rb +30 -185
- metadata +56 -24
- data/lib/songsplitter.rb +0 -38
- data/test/examples/combined.wav +0 -0
- data/test/examples/split-bass.wav +0 -0
- data/test/examples/split-hh_closed.wav +0 -0
- data/test/examples/split-snare.wav +0 -0
- data/test/examples/split-tom2.wav +0 -0
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Song:
|
4
4
|
Tempo: 120
|
5
|
-
|
5
|
+
Flow:
|
6
6
|
- Verse: x2
|
7
7
|
- Chorus: x4
|
8
8
|
- Verse: x2
|
@@ -16,13 +16,15 @@ Song:
|
|
16
16
|
Verse:
|
17
17
|
- bass: X...X...X...X...
|
18
18
|
- snare: ..............X.
|
19
|
-
- hh_closed: X.XXX.
|
19
|
+
- hh_closed: X.XXX.XX........
|
20
|
+
- hh_closed: ........X.X.X.X.
|
20
21
|
- agogo: ..............XX
|
21
22
|
|
22
23
|
# Also including non-Kit sounds to test that they work as well:
|
23
24
|
Chorus:
|
24
25
|
- bass: X...X...XX..X...
|
25
26
|
- snare: ....X.......X...
|
26
|
-
- hh_closed: X.XXX.
|
27
|
+
- hh_closed: X.XXX.XX........
|
28
|
+
- hh_closed: ........X.XX..X.
|
27
29
|
- ../../sounds/tom4_mono_16.wav: ...........X....
|
28
30
|
- ../../sounds/tom2_mono_16.wav: ..............X.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Song:
|
4
4
|
Tempo: 120
|
5
|
-
|
5
|
+
Flow:
|
6
6
|
- Verse: x2
|
7
7
|
- Chorus: x4
|
8
8
|
- Verse: x2
|
@@ -16,13 +16,15 @@ Song:
|
|
16
16
|
Verse:
|
17
17
|
- bass: X...X...X...X...
|
18
18
|
- snare: ..............X.
|
19
|
-
- hh_closed: X.XXX.
|
19
|
+
- hh_closed: X.XXX.XX........
|
20
|
+
- hh_closed: ........X.X.X.X.
|
20
21
|
- agogo: ..............XX
|
21
22
|
|
22
23
|
# Also including non-Kit sounds to test that they work as well:
|
23
24
|
Chorus:
|
24
25
|
- bass: X...X...XX..X...
|
25
26
|
- snare: ....X.......X...
|
26
|
-
- hh_closed: X.XXX.
|
27
|
+
- hh_closed: X.XXX.XX........
|
28
|
+
- hh_closed: ........X.XX..X.
|
27
29
|
- ../../sounds/tom4_mono_8.wav: ...........X....
|
28
30
|
- ../../sounds/tom2_mono_8.wav: ..............X.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Song:
|
4
4
|
Tempo: 120
|
5
|
-
|
5
|
+
Flow:
|
6
6
|
- Verse: x2
|
7
7
|
- Chorus: x4
|
8
8
|
- Verse: x2
|
@@ -16,13 +16,16 @@ Song:
|
|
16
16
|
Verse:
|
17
17
|
- bass: X...X...X...X...
|
18
18
|
- snare: ..............X.
|
19
|
-
- hh_closed: X.XXX.
|
19
|
+
- hh_closed: X.XXX.XX........
|
20
|
+
- hh_closed: ........X.X.X.X.
|
20
21
|
- agogo: ..............XX
|
21
22
|
|
22
23
|
# Also including non-Kit sounds to test that they work as well:
|
23
24
|
Chorus:
|
24
25
|
- bass: X...X...XX..X...
|
25
26
|
- snare: ....X.......X...
|
26
|
-
- hh_closed: X.XXX.
|
27
|
+
- hh_closed: X.XXX.XX........
|
28
|
+
- hh_closed: ........X.XX..X.
|
27
29
|
- ../../sounds/tom4_stereo_16.wav: ...........X....
|
28
|
-
- ../../sounds/tom2_stereo_16.wav: ..............X.
|
30
|
+
- ../../sounds/tom2_stereo_16.wav: ..............X.
|
31
|
+
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Song:
|
4
4
|
Tempo: 120
|
5
|
-
|
5
|
+
Flow:
|
6
6
|
- Verse: x2
|
7
7
|
- Chorus: x4
|
8
8
|
- Verse: x2
|
@@ -16,13 +16,15 @@ Song:
|
|
16
16
|
Verse:
|
17
17
|
- bass: X...X...X...X...
|
18
18
|
- snare: ..............X.
|
19
|
-
- hh_closed: X.XXX.
|
19
|
+
- hh_closed: X.XXX.XX........
|
20
|
+
- hh_closed: ........X.X.X.X.
|
20
21
|
- agogo: ..............XX
|
21
22
|
|
22
23
|
# Also including non-Kit sounds to test that they work as well:
|
23
24
|
Chorus:
|
24
25
|
- bass: X...X...XX..X...
|
25
26
|
- snare: ....X.......X...
|
26
|
-
- hh_closed: X.XXX.
|
27
|
+
- hh_closed: X.XXX.XX........
|
28
|
+
- hh_closed: ........X.XX..X.
|
27
29
|
- ../../sounds/tom4_stereo_8.wav: ...........X....
|
28
30
|
- ../../sounds/tom2_stereo_8.wav: ..............X.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# A song in which a pattern has multiple tracks that use the same sound
|
2
|
+
# The output should be the same as example_mono_16.txt
|
3
|
+
# TODO: Add integration tests to verify correct output
|
4
|
+
|
5
|
+
Song:
|
6
|
+
Tempo: 120
|
7
|
+
Flow:
|
8
|
+
- Verse: x2
|
9
|
+
- Chorus: x4
|
10
|
+
- Verse: x2
|
11
|
+
- Chorus: x4
|
12
|
+
Kit:
|
13
|
+
- bass: test/sounds/bass_mono_16.wav
|
14
|
+
- snare: test/sounds/snare_mono_16.wav
|
15
|
+
- hh_closed: test/sounds/hh_closed_mono_16.wav
|
16
|
+
- agogo: test/sounds/agogo_high_mono_16.wav
|
17
|
+
|
18
|
+
Verse:
|
19
|
+
- bass: X...............
|
20
|
+
- bass: ....X...........
|
21
|
+
- bass: ........X.......
|
22
|
+
- bass: ............X...
|
23
|
+
- snare: ..............X.
|
24
|
+
- hh_closed: X.XXX.XXX.X.X.X.
|
25
|
+
- agogo: ..............XX
|
26
|
+
|
27
|
+
# Also including non-Kit sounds to test that they work as well:
|
28
|
+
Chorus:
|
29
|
+
- bass: X...X...XX..X...
|
30
|
+
- snare: ....X.......X...
|
31
|
+
- hh_closed: X.XXX.XXX.XX..X.
|
32
|
+
- test/sounds/tom4_mono_16.wav: ...........X....
|
33
|
+
- test/sounds/tom2_mono_16.wav: ..............X.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Test fixture to verify SongOptimizer bug fix.
|
2
|
+
#
|
3
|
+
# SongOptimizer.subdivide_song_patterns() breaks up patterns into smaller sub-patterns. The bug
|
4
|
+
# was that when master patterns had numeric suffixes, new sub-patterns could be given names that
|
5
|
+
# collided with other sub-patterns. If they had different rhythms, one sub-pattern would obliterate
|
6
|
+
# the other one leading to incorrect song output.
|
7
|
+
#
|
8
|
+
# In the example below, when sub-dividing patterns with a max size of 4 steps, the new patterns
|
9
|
+
# highlighted with !!!! would both be called Verse20, causing a collision.
|
10
|
+
|
11
|
+
|
12
|
+
Song:
|
13
|
+
Flow:
|
14
|
+
- Verse
|
15
|
+
- Verse2
|
16
|
+
|
17
|
+
|
18
|
+
Verse:
|
19
|
+
# 0 4 8 12 16 20
|
20
|
+
# !!!!
|
21
|
+
- test/sounds/bass_mono_8.wav: |X...|X...|X...|X...|X...|X.XX|
|
22
|
+
|
23
|
+
|
24
|
+
Verse2:
|
25
|
+
# 0 4 8 12 16 20
|
26
|
+
# !!!!
|
27
|
+
- test/sounds/bass_mono_8.wav: |X..X|X..X|X..X|X..X|X..X|X..X|
|
28
|
+
|
@@ -1,9 +1,9 @@
|
|
1
|
-
# The pattern Verse in the
|
1
|
+
# The pattern Verse in the flow doesn't specify how many times it should repeat.
|
2
2
|
# This is valid, it causes it to default to 1 repeat.
|
3
3
|
|
4
4
|
Song:
|
5
5
|
Tempo: 100
|
6
|
-
|
6
|
+
Flow:
|
7
7
|
- Verse
|
8
8
|
|
9
9
|
Verse:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Song:
|
2
2
|
Tempo: 99
|
3
|
-
|
3
|
+
Flow:
|
4
4
|
- Verse: x2
|
5
5
|
- Chorus: x2
|
6
6
|
- Verse: x2
|
@@ -8,10 +8,10 @@ Song:
|
|
8
8
|
- Bridge: x1
|
9
9
|
- Chorus: x4
|
10
10
|
Kit:
|
11
|
-
- bass:
|
12
|
-
- hhclosed:
|
13
|
-
- hhopen:
|
14
|
-
- snare:
|
11
|
+
- bass: bass_mono_8.wav
|
12
|
+
- hhclosed: hh_closed_mono_8.wav
|
13
|
+
- hhopen: hh_open_mono_8.wav
|
14
|
+
- snare: snare_mono_8.wav
|
15
15
|
|
16
16
|
Bridge:
|
17
17
|
- hhclosed: XX.XXX.XXX.XXX.XXX.XXX.XXX.XXX.X
|
data/test/includes.rb
CHANGED
@@ -5,12 +5,14 @@ require 'rubygems'
|
|
5
5
|
require 'wavefile'
|
6
6
|
|
7
7
|
# BEATS classes
|
8
|
+
require 'audioengine'
|
9
|
+
require 'audioutils'
|
8
10
|
require 'beats'
|
9
11
|
require 'kit'
|
10
12
|
require 'pattern'
|
13
|
+
require 'patternexpander'
|
11
14
|
require 'song'
|
12
15
|
require 'songparser'
|
13
16
|
require 'songoptimizer'
|
14
|
-
require 'songsplitter'
|
15
17
|
require 'track'
|
16
|
-
require 'beatswavefile'
|
18
|
+
require 'beatswavefile'
|
data/test/integration.rb
CHANGED
@@ -3,15 +3,15 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
|
3
3
|
require 'test/includes'
|
4
4
|
|
5
5
|
class SongParserTest < Test::Unit::TestCase
|
6
|
-
TRACK_NAMES = ["bass", "snare", "hh_closed", "agogo", "tom4", "tom2"]
|
6
|
+
TRACK_NAMES = ["bass", "snare", "hh_closed", "hh_closed2", "agogo", "tom4", "tom2"]
|
7
7
|
OUTPUT_FOLDER = "test/integration_output"
|
8
8
|
|
9
9
|
def test_bad_song_errors
|
10
10
|
invalid_fixtures = ["bad_tempo.txt",
|
11
11
|
"bad_repeat_count.txt",
|
12
|
-
"
|
12
|
+
"bad_flow.txt",
|
13
13
|
"no_header.txt",
|
14
|
-
"
|
14
|
+
"no_flow.txt",
|
15
15
|
"sound_in_kit_not_found.txt",
|
16
16
|
"sound_in_track_not_found.txt"]
|
17
17
|
|
data/test/kit_test.rb
CHANGED
@@ -2,125 +2,152 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
|
2
2
|
|
3
3
|
require 'test/includes'
|
4
4
|
|
5
|
-
|
5
|
+
# Kit which allows directly changing the sound bank after initialization, to allows tests
|
6
|
+
# to use fixture data directly in the test instead of loading it from the file system.
|
7
|
+
class MutableKit < Kit
|
8
|
+
attr_accessor :sound_bank
|
9
|
+
end
|
10
|
+
|
11
|
+
class KitTest < Test::Unit::TestCase
|
6
12
|
MIN_SAMPLE_8BIT = 0
|
7
13
|
MAX_SAMPLE_8BIT = 255
|
8
14
|
|
9
|
-
def
|
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
|
-
assert_equal(2, kit.num_channels)
|
37
|
-
kit.add("mono16", "bass_mono_16.wav")
|
38
|
-
assert_equal(16, kit.bits_per_sample)
|
39
|
-
assert_equal(2, kit.num_channels)
|
40
|
-
kit.add("mono8", "bass_mono_8.wav")
|
41
|
-
assert_equal(16, kit.bits_per_sample)
|
42
|
-
assert_equal(2, kit.num_channels)
|
15
|
+
def generate_test_data
|
16
|
+
kits = {}
|
17
|
+
|
18
|
+
# Kit with no sounds
|
19
|
+
kits[:empty] = Kit.new("test/sounds", {})
|
20
|
+
|
21
|
+
# Kits which only has simple sounds
|
22
|
+
kits[:mono8] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav"})
|
23
|
+
kits[:mono16] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
24
|
+
"mono16" => "bass_mono_16.wav"})
|
25
|
+
kits[:stereo8] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
26
|
+
"stereo8" => "bass_stereo_8.wav"})
|
27
|
+
kits[:stereo16] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
28
|
+
"mono16" => "bass_mono_16.wav",
|
29
|
+
"stereo16" => "bass_stereo_16.wav"})
|
30
|
+
|
31
|
+
# Kits which contain a composite sound
|
32
|
+
#kits[:basic_composite] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
33
|
+
# "composite_mono8" => ["snare_mono_8.wav", "tom3_mono_8.wav"]})
|
34
|
+
#kits[:mismatched_bps_composite] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
35
|
+
# "composite_mono16" => ["snare_mono_8.wav", "tom3_mono_16.wav"]})
|
36
|
+
#kits[:mismatched_channels_composite] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
37
|
+
# "composite_stereo16" => ["snare_stereo_16.wav", "tom3_mono_16.wav"]})
|
38
|
+
#kits[:mismatched_everything_composite] = Kit.new("test/sounds", {"mono8" => "bass_mono_8.wav",
|
39
|
+
# "composite_stereo16" => ["snare_stereo_8.wav", "tom3_mono_16.wav"]})
|
40
|
+
|
41
|
+
return kits
|
43
42
|
end
|
44
43
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
44
|
+
def test_valid_initialization
|
45
|
+
kits = generate_test_data()
|
46
|
+
|
47
|
+
assert_equal(16, kits[:empty].bits_per_sample)
|
48
|
+
assert_equal(1, kits[:empty].num_channels)
|
49
|
+
|
50
|
+
assert_equal(16, kits[:mono8].bits_per_sample)
|
51
|
+
assert_equal(1, kits[:mono8].num_channels)
|
52
|
+
|
53
|
+
assert_equal(16, kits[:mono16].bits_per_sample)
|
54
|
+
assert_equal(1, kits[:mono16].num_channels)
|
55
|
+
|
56
|
+
assert_equal(16, kits[:stereo8].bits_per_sample)
|
57
|
+
assert_equal(2, kits[:stereo8].num_channels)
|
58
|
+
|
59
|
+
assert_equal(16, kits[:stereo16].bits_per_sample)
|
60
|
+
assert_equal(2, kits[:stereo16].num_channels)
|
61
|
+
|
62
|
+
#assert_equal(16, kits[:basic_composite].bits_per_sample)
|
63
|
+
#assert_equal(1, kits[:basic_composite].num_channels)
|
64
|
+
|
65
|
+
#assert_equal(16, kits[:mismatched_bps_composite].bits_per_sample)
|
66
|
+
#assert_equal(1, kits[:mismatched_bps_composite].num_channels)
|
67
|
+
|
68
|
+
#assert_equal(16, kits[:mismatched_channels_composite].bits_per_sample)
|
69
|
+
#assert_equal(2, kits[:mismatched_channels_composite].num_channels)
|
70
|
+
|
71
|
+
#assert_equal(16, kits[:mismatched_everything_composite].bits_per_sample)
|
72
|
+
#assert_equal(2, kits[:mismatched_everything_composite].num_channels)
|
48
73
|
end
|
49
|
-
|
74
|
+
|
75
|
+
def test_invalid_initialization
|
76
|
+
# Tests for adding non-existant sound file to Kit
|
77
|
+
assert_raise(SoundFileNotFoundError) { Kit.new("test/sounds", {"i_do_not_exist" => "i_do_not_exist.wav"}) }
|
78
|
+
|
79
|
+
assert_raise(SoundFileNotFoundError) { Kit.new("test/sounds", {"mono16" => "bass_mono_16.wav",
|
80
|
+
"i_do_not_exist" => "i_do_not_exist.wav"}) }
|
81
|
+
|
82
|
+
#assert_raise(SoundFileNotFoundError) { Kit.new("test/sounds", {"mono16" => "bass_mono_16.wav",
|
83
|
+
# "composite" => ["bass_mono_16.wav", "snare_mono_16.wav"],
|
84
|
+
# "i_do_not_exist" => "i_do_not_exist.wav"}) }
|
85
|
+
|
86
|
+
# Tests for adding invalid sound files to Kit
|
87
|
+
assert_raise(InvalidSoundFormatError) { Kit.new("test", {"bad" => "kit_test.rb"}) }
|
88
|
+
|
89
|
+
assert_raise(InvalidSoundFormatError) { Kit.new("test", {"mono16" => "sounds/bass_mono_16.wav",
|
90
|
+
"bad" => "kit_test.rb"}) }
|
91
|
+
|
92
|
+
#assert_raise(InvalidSoundFormatError) { Kit.new("test", {"mono16" => "sounds/bass_mono_16.wav",
|
93
|
+
# "composite" => ["sounds/bass_mono_16.wav", "sounds/snare_mono_16.wav"],
|
94
|
+
# "bad" => "kit_test.rb"}) }
|
95
|
+
end
|
96
|
+
|
50
97
|
def test_get_sample_data
|
51
|
-
|
52
|
-
|
53
|
-
assert_raise(StandardError) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
sample_data.each do |sample|
|
63
|
-
all_are_fixnums &&= sample.class == Fixnum
|
64
|
-
end
|
65
|
-
assert(all_are_fixnums)
|
66
|
-
|
67
|
-
kit.add("mono16", "bass_mono_16.wav")
|
68
|
-
sample_data = kit.get_sample_data("mono8")
|
69
|
-
assert(sample_data.max > MAX_SAMPLE_8BIT)
|
70
|
-
assert(sample_data.min < 0)
|
71
|
-
all_are_fixnums = true
|
72
|
-
sample_data.each do |sample|
|
73
|
-
all_are_fixnums &&= sample.class == Fixnum
|
98
|
+
kits = generate_test_data()
|
99
|
+
# Should get an error when trying to get a non-existent sound
|
100
|
+
assert_raise(StandardError) { kits[:mono8].get_sample_data("nonexistant") }
|
101
|
+
|
102
|
+
[:mono8, :mono16].each do |kit_name|
|
103
|
+
sample_data = kits[kit_name].get_sample_data("mono8")
|
104
|
+
# Assert sample data is 16-bit. If max and min samples are outside 0-255 bounds, then it is.
|
105
|
+
assert(sample_data.max > MAX_SAMPLE_8BIT)
|
106
|
+
assert(sample_data.min < MIN_SAMPLE_8BIT)
|
107
|
+
# Assert it has 1 channel. This is true if every item is a Fixnum.
|
108
|
+
assert_equal([], sample_data.select {|sample| sample.class != Fixnum})
|
74
109
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
all_are_arrays &&= sample.class == Array
|
110
|
+
|
111
|
+
[:stereo8, :stereo16].each do |kit_name|
|
112
|
+
sample_data = kits[kit_name].get_sample_data("mono8")
|
113
|
+
# Assert sample data is 16-bit. If max and min samples are outside 0-255 bounds, then it is.
|
114
|
+
assert(sample_data.flatten.max > MAX_SAMPLE_8BIT)
|
115
|
+
assert(sample_data.flatten.min < MIN_SAMPLE_8BIT)
|
116
|
+
# Assert it has 2 channels. This is true if every item is an Array.
|
117
|
+
assert_equal([], sample_data.select {|sample| sample.class != Array})
|
84
118
|
end
|
85
|
-
assert(all_are_arrays)
|
86
|
-
assert(sample_data.first.length == 2)
|
87
119
|
|
120
|
+
#actual_sample_data = kits[:basic_composite].get_sample_data("composite_mono8")
|
121
|
+
#expected_sample_data = WaveFile.open("test/sounds/composite_snare_mono_8_tom3_mono_8_mono_16.wav").sample_data
|
122
|
+
#assert_equal(expected_sample_data, actual_sample_data)
|
88
123
|
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
124
|
+
#actual_sample_data = kits[:mismatched_bps_composite].get_sample_data("composite_mono16")
|
125
|
+
#expected_sample_data = WaveFile.open("test/sounds/composite_snare_mono_8_tom3_mono_16_mono_16.wav").sample_data
|
126
|
+
#assert_equal(expected_sample_data, actual_sample_data)
|
92
127
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
kit.
|
116
|
-
|
117
|
-
assert(sample_data.flatten.max > MAX_SAMPLE_8BIT)
|
118
|
-
assert(sample_data.flatten.min < 0)
|
119
|
-
all_are_arrays = true
|
120
|
-
sample_data.each do |sample|
|
121
|
-
all_are_arrays &&= sample.class == Array
|
122
|
-
end
|
123
|
-
assert(all_are_arrays)
|
124
|
-
assert(sample_data.first.length == 2)
|
128
|
+
#actual_sample_data = kits[:mismatched_channels_composite].get_sample_data("composite_stereo16")
|
129
|
+
#expected_sample_data = WaveFile.open("test/sounds/composite_snare_stereo_16_tom3_mono_16_stereo_16.wav").sample_data
|
130
|
+
#assert_equal(expected_sample_data, actual_sample_data)
|
131
|
+
|
132
|
+
#actual_sample_data = kits[:mismatched_everything_composite].get_sample_data("composite_stereo16")
|
133
|
+
#expected_sample_data = WaveFile.open("test/sounds/composite_snare_stereo_8_tom3_mono_16_stereo_16.wav").sample_data
|
134
|
+
#assert_equal(expected_sample_data[0..10], actual_sample_data[0..10])
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_scale!
|
138
|
+
sound_bank = {"a" => [-10, 0, 20], "b" => [], "c" => [12346, 9999]}
|
139
|
+
|
140
|
+
kit = MutableKit.new(".", {})
|
141
|
+
kit.sound_bank = sound_bank
|
142
|
+
|
143
|
+
kit.scale!(5)
|
144
|
+
assert_equal([-2, 0, 4], kit.get_sample_data("a"))
|
145
|
+
assert_equal([], kit.get_sample_data("b"))
|
146
|
+
assert_equal([2469, 1999], kit.get_sample_data("c"))
|
147
|
+
|
148
|
+
kit.scale!(2)
|
149
|
+
assert_equal([-1, 0, 2], kit.get_sample_data("a"))
|
150
|
+
assert_equal([], kit.get_sample_data("b"))
|
151
|
+
assert_equal([1234, 999], kit.get_sample_data("c"))
|
125
152
|
end
|
126
|
-
end
|
153
|
+
end
|