viking-bloopsaphone 0.4 → 0.4.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/README +8 -13
- data/c/bloopsaphone.c +327 -440
- data/c/bloopsaphone.h +23 -82
- data/c/notation.c +186 -633
- data/ext/ruby/extconf.rb +3 -4
- data/ext/ruby/rubyext.c +23 -63
- data/ext/ruby/test.rb +3 -18
- data/ext/ruby/test_record.rb +24 -0
- metadata +10 -14
- data/c/threads.h +0 -46
- data/sounds/dart.blu +0 -10
- data/sounds/error.blu +0 -13
- data/sounds/ice.blu +0 -5
- data/sounds/jump.blu +0 -8
- data/sounds/pogo.blu +0 -19
- data/sounds/stun.blu +0 -6
data/ext/ruby/extconf.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
$CFLAGS << " -I../../c
|
5
|
-
$LIBS << " -lm -lportaudio #{ENV['LDFLAGS']}"
|
4
|
+
$CFLAGS << " -I../../c "
|
6
5
|
|
7
|
-
%w[notation.c
|
8
|
-
fn = "../../c/#{fn}"
|
6
|
+
%w[../../c/notation.c ../../c/bloopsaphone.c ../../c/bloopsaphone.h].each do |fn|
|
9
7
|
abort "!! ERROR !!\n** #{fn} not found; type 'make ruby' in the top directory\n\n" \
|
10
8
|
unless File.exists? fn
|
11
9
|
FileUtils.cp(fn, ".")
|
12
10
|
end
|
13
11
|
|
14
12
|
have_library("portaudio")
|
13
|
+
have_library("sndfile")
|
15
14
|
create_makefile("bloops")
|
data/ext/ruby/rubyext.c
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
#include "bloopsaphone.h"
|
9
9
|
|
10
10
|
static VALUE cBloops, cSound, cTrack;
|
11
|
-
static bloopsaphone *Pplain;
|
12
11
|
|
13
12
|
#ifndef RSTRING_LEN
|
14
13
|
#define RSTRING_LEN(str) RSTRING(str)->len
|
@@ -49,6 +48,15 @@ rb_bloops_play(VALUE self)
|
|
49
48
|
return self;
|
50
49
|
}
|
51
50
|
|
51
|
+
VALUE
|
52
|
+
rb_bloops_record(VALUE self, VALUE path)
|
53
|
+
{
|
54
|
+
bloops *B;
|
55
|
+
Data_Get_Struct(self, bloops, B);
|
56
|
+
int result = bloops_record(B, StringValuePtr(path));
|
57
|
+
return self;
|
58
|
+
}
|
59
|
+
|
52
60
|
VALUE
|
53
61
|
rb_bloops_is_stopped(VALUE self)
|
54
62
|
{
|
@@ -80,7 +88,7 @@ rb_bloops_set_tempo(VALUE self, VALUE tempo)
|
|
80
88
|
static void
|
81
89
|
rb_bloops_sound_free(bloopsaphone *sound)
|
82
90
|
{
|
83
|
-
|
91
|
+
free(sound);
|
84
92
|
}
|
85
93
|
|
86
94
|
VALUE
|
@@ -100,65 +108,16 @@ VALUE
|
|
100
108
|
rb_bloops_sound(VALUE self, VALUE type)
|
101
109
|
{
|
102
110
|
bloopsaphone *P = bloops_square();
|
103
|
-
P->
|
111
|
+
P->type = (unsigned char)NUM2INT(type);
|
104
112
|
return Data_Wrap_Struct(cSound, NULL, rb_bloops_sound_free, P);
|
105
113
|
}
|
106
114
|
|
107
|
-
VALUE
|
108
|
-
rb_bloops_sound_copy(VALUE self, VALUE other)
|
109
|
-
{
|
110
|
-
bloopsaphone *P;
|
111
|
-
bloopsaphone *O;
|
112
|
-
Data_Get_Struct(self, bloopsaphone, P);
|
113
|
-
Data_Get_Struct(other, bloopsaphone, O);
|
114
|
-
bloops_sound_copy(P, O);
|
115
|
-
return Qnil;
|
116
|
-
}
|
117
|
-
|
118
|
-
VALUE
|
119
|
-
rb_bloops_sound_str(VALUE self)
|
120
|
-
{
|
121
|
-
bloopsaphone *P;
|
122
|
-
Data_Get_Struct(self, bloopsaphone, P);
|
123
|
-
return rb_str_new2(bloops_sound_str(P));
|
124
|
-
}
|
125
|
-
|
126
|
-
VALUE
|
127
|
-
rb_bloops_reset(VALUE self)
|
128
|
-
{
|
129
|
-
bloopsaphone *P;
|
130
|
-
Data_Get_Struct(self, bloopsaphone, P);
|
131
|
-
bloops_sound_copy(P, Pplain);
|
132
|
-
return self;
|
133
|
-
}
|
134
|
-
|
135
|
-
VALUE
|
136
|
-
rb_bloops_test(VALUE self)
|
137
|
-
{
|
138
|
-
bloops *B;
|
139
|
-
bloopsatrack *T;
|
140
|
-
bloopsaphone *P;
|
141
|
-
|
142
|
-
Data_Get_Struct(self, bloopsaphone, P);
|
143
|
-
|
144
|
-
B = bloops_new();
|
145
|
-
bloops_tempo(B, 120);
|
146
|
-
T = bloops_track2(B, P, "C");
|
147
|
-
T->notes[0].tone = 'n';
|
148
|
-
memcpy(&T->params, &P->params, sizeof(bloopsaparams));
|
149
|
-
bloops_play(B);
|
150
|
-
bloops_track_destroy(T);
|
151
|
-
bloops_destroy(B);
|
152
|
-
|
153
|
-
return self;
|
154
|
-
}
|
155
|
-
|
156
115
|
VALUE
|
157
116
|
rb_bloops_get_type(VALUE self)
|
158
117
|
{
|
159
118
|
bloopsaphone *P;
|
160
119
|
Data_Get_Struct(self, bloopsaphone, P);
|
161
|
-
return INT2NUM((int)P->
|
120
|
+
return INT2NUM((int)P->type);
|
162
121
|
}
|
163
122
|
|
164
123
|
VALUE
|
@@ -166,7 +125,7 @@ rb_bloops_set_type(VALUE self, VALUE type)
|
|
166
125
|
{
|
167
126
|
bloopsaphone *P;
|
168
127
|
Data_Get_Struct(self, bloopsaphone, P);
|
169
|
-
P->
|
128
|
+
P->type = (unsigned char)NUM2INT(type);
|
170
129
|
return type;
|
171
130
|
}
|
172
131
|
|
@@ -174,12 +133,12 @@ rb_bloops_set_type(VALUE self, VALUE type)
|
|
174
133
|
VALUE rb_bloops_get_##name(VALUE self) { \
|
175
134
|
bloopsaphone *P; \
|
176
135
|
Data_Get_Struct(self, bloopsaphone, P); \
|
177
|
-
return rb_float_new(P->
|
136
|
+
return rb_float_new(P->name); \
|
178
137
|
} \
|
179
138
|
VALUE rb_bloops_set_##name(VALUE self, VALUE f) { \
|
180
139
|
bloopsaphone *P; \
|
181
140
|
Data_Get_Struct(self, bloopsaphone, P); \
|
182
|
-
P->
|
141
|
+
P->name = (float)NUM2DBL(f); \
|
183
142
|
return f; \
|
184
143
|
}
|
185
144
|
|
@@ -220,6 +179,7 @@ rb_bloops_track_free(bloopsatrack *track)
|
|
220
179
|
VALUE
|
221
180
|
rb_bloops_tune(VALUE self, VALUE sound, VALUE notes)
|
222
181
|
{
|
182
|
+
int i;
|
223
183
|
bloops *B;
|
224
184
|
bloopsaphone *phone;
|
225
185
|
bloopsatrack *track;
|
@@ -228,6 +188,12 @@ rb_bloops_tune(VALUE self, VALUE sound, VALUE notes)
|
|
228
188
|
|
229
189
|
StringValue(notes);
|
230
190
|
track = bloops_track(B, phone, RSTRING_PTR(notes), RSTRING_LEN(notes));
|
191
|
+
|
192
|
+
for (i = 0; i < BLOOPS_MAX_TRACKS; i++)
|
193
|
+
if (B->tracks[i] == NULL) {
|
194
|
+
bloops_track_at(B, track, i);
|
195
|
+
break;
|
196
|
+
}
|
231
197
|
return Data_Wrap_Struct(cTrack, NULL, rb_bloops_track_free, track);
|
232
198
|
}
|
233
199
|
|
@@ -252,15 +218,13 @@ rb_bloops_track_str(VALUE self)
|
|
252
218
|
void
|
253
219
|
Init_bloops()
|
254
220
|
{
|
255
|
-
Pplain = bloops_square();
|
256
|
-
|
257
221
|
cBloops = rb_define_class("Bloops", rb_cObject);
|
258
222
|
rb_define_alloc_func(cBloops, rb_bloops_alloc);
|
259
223
|
rb_define_method(cBloops, "clear", rb_bloops_clear, 0);
|
260
224
|
rb_define_method(cBloops, "load", rb_bloops_load, 1);
|
261
225
|
rb_define_method(cBloops, "play", rb_bloops_play, 0);
|
226
|
+
rb_define_method(cBloops, "record", rb_bloops_record, 1);
|
262
227
|
rb_define_method(cBloops, "sound", rb_bloops_sound, 1);
|
263
|
-
rb_define_singleton_method(cBloops, "sound", rb_bloops_sound, 1);
|
264
228
|
rb_define_method(cBloops, "stopped?", rb_bloops_is_stopped, 0);
|
265
229
|
rb_define_method(cBloops, "tempo", rb_bloops_get_tempo, 0);
|
266
230
|
rb_define_method(cBloops, "tempo=", rb_bloops_set_tempo, 1);
|
@@ -272,10 +236,6 @@ Init_bloops()
|
|
272
236
|
rb_const_set(cBloops, rb_intern("NOISE"), INT2NUM(BLOOPS_NOISE));
|
273
237
|
|
274
238
|
cSound = rb_define_class_under(cBloops, "Sound", rb_cObject);
|
275
|
-
rb_define_method(cSound, "initialize_copy", rb_bloops_sound_copy, 1);
|
276
|
-
rb_define_method(cSound, "to_s", rb_bloops_sound_str, 0);
|
277
|
-
rb_define_method(cSound, "reset", rb_bloops_reset, 0);
|
278
|
-
rb_define_method(cSound, "test", rb_bloops_test, 0);
|
279
239
|
rb_define_method(cSound, "arp", rb_bloops_get_arp, 0);
|
280
240
|
rb_define_method(cSound, "arp=", rb_bloops_set_arp, 1);
|
281
241
|
rb_define_method(cSound, "aspeed", rb_bloops_get_aspeed, 0);
|
data/ext/ruby/test.rb
CHANGED
@@ -6,7 +6,6 @@ b.tempo = 320
|
|
6
6
|
|
7
7
|
# an instrument
|
8
8
|
saw = b.sound Bloops::SAWTOOTH
|
9
|
-
saw.test
|
10
9
|
|
11
10
|
# assign a track to the song
|
12
11
|
b.tune saw, "c5 c6 b4 b5 d5 d6 e5 e6"
|
@@ -18,24 +17,10 @@ sleep 1 while !b.stopped?
|
|
18
17
|
# a percussion
|
19
18
|
beat = b.sound Bloops::NOISE
|
20
19
|
beat.repeat = 0.6
|
21
|
-
beat2 = b.sound Bloops::NOISE
|
22
|
-
beat2.repeat = 0.2
|
23
|
-
beat3 = b.sound Bloops::SQUARE
|
24
|
-
beat3.sustain = 0.25
|
25
|
-
beat3.decay = 0.2
|
26
|
-
beat3.slide = 0.2
|
27
|
-
beat3.square = 0.3
|
28
|
-
beat3.vibe = 0.25
|
29
|
-
beat3.vspeed = 0.25
|
30
20
|
|
31
21
|
# assign a track to the song
|
32
|
-
b.tune beat, "4 4
|
33
|
-
b.tune beat2, "c2 4 c2 4 c2 4 c2 4"
|
34
|
-
b.tune beat3, "4 4 4 4 4 c2 c5 4"
|
22
|
+
b.tune beat, "4 4 b4 4 d5 4 e5 e6"
|
35
23
|
|
36
24
|
# make it go
|
37
|
-
|
38
|
-
|
39
|
-
saw.test
|
40
|
-
sleep 0.02 while !b.stopped?
|
41
|
-
end
|
25
|
+
b.play
|
26
|
+
sleep 1 while !b.stopped?
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require './bloops'
|
2
|
+
|
3
|
+
# the song object
|
4
|
+
b = Bloops.new
|
5
|
+
b.tempo = 320
|
6
|
+
|
7
|
+
# an instrument
|
8
|
+
saw = b.sound Bloops::SAWTOOTH
|
9
|
+
|
10
|
+
# assign a track to the song
|
11
|
+
b.tune saw, "c5 c6 b4 b5 d5 d6 e5 e6"
|
12
|
+
|
13
|
+
# make it go
|
14
|
+
b.record("out1.wav")
|
15
|
+
|
16
|
+
# a percussion
|
17
|
+
beat = b.sound Bloops::NOISE
|
18
|
+
beat.repeat = 0.6
|
19
|
+
|
20
|
+
# assign a track to the song
|
21
|
+
b.tune beat, "4 4 b4 4 d5 4 e5 e6"
|
22
|
+
|
23
|
+
# make it go
|
24
|
+
b.record("out2.wav")
|
metadata
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viking-bloopsaphone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- why the lucky stiff
|
8
|
+
- Jeremy Stephens
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-
|
13
|
+
date: 2009-09-26 00:00:00 -05:00
|
13
14
|
default_executable:
|
14
15
|
dependencies: []
|
15
16
|
|
16
17
|
description: arcade sounds and chiptunes
|
17
|
-
email:
|
18
|
+
email: viking415@gmail.com
|
18
19
|
executables: []
|
19
20
|
|
20
21
|
extensions:
|
@@ -28,20 +29,15 @@ files:
|
|
28
29
|
- c/bloopsaphone.c
|
29
30
|
- c/bloopsaphone.h
|
30
31
|
- c/notation.c
|
31
|
-
- c/threads.h
|
32
32
|
- ext/ruby/extconf.rb
|
33
33
|
- ext/ruby/rubyext.c
|
34
34
|
- ext/ruby/test.rb
|
35
35
|
- ext/ruby/test_load.rb
|
36
|
-
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- sounds/stun.blu
|
42
|
-
has_rdoc: false
|
43
|
-
homepage: http://github.com/why/bloopsaphone
|
44
|
-
licenses:
|
36
|
+
- ext/ruby/test_record.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/viking/bloopsaphone
|
39
|
+
licenses: []
|
40
|
+
|
45
41
|
post_install_message:
|
46
42
|
rdoc_options: []
|
47
43
|
|
@@ -64,7 +60,7 @@ requirements: []
|
|
64
60
|
rubyforge_project:
|
65
61
|
rubygems_version: 1.3.5
|
66
62
|
signing_key:
|
67
|
-
specification_version:
|
63
|
+
specification_version: 3
|
68
64
|
summary: arcade sounds and chiptunes
|
69
65
|
test_files: []
|
70
66
|
|
data/c/threads.h
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// threads.h - threaded garments for the bloopsaphone
|
3
|
-
//
|
4
|
-
#ifndef BLOOPSAPHONE_THREADS_H
|
5
|
-
#define BLOOPSAPHONE_THREADS_H
|
6
|
-
|
7
|
-
#ifdef _WIN32
|
8
|
-
#include <windows.h>
|
9
|
-
typedef CRITICAL_SECTION bloopsalock;
|
10
|
-
static inline void bloops_lock_init(bloopsalock *lock) {
|
11
|
-
InitializeCriticalSection(lock);
|
12
|
-
}
|
13
|
-
static inline void bloops_lock_acquire(bloopsalock *lock) {
|
14
|
-
EnterCriticalSection(lock);
|
15
|
-
}
|
16
|
-
static inline int bloops_lock_try_acquire(bloopsalock *lock) {
|
17
|
-
return !!TryEnterCriticalSection(lock);
|
18
|
-
}
|
19
|
-
static inline void bloops_lock_release(bloopsalock *lock) {
|
20
|
-
LeaveCriticalSection(lock);
|
21
|
-
}
|
22
|
-
static inline void bloops_lock_finalize(bloopsalock *lock) {
|
23
|
-
DeleteCriticalSection(lock);
|
24
|
-
}
|
25
|
-
#else
|
26
|
-
#include <pthread.h>
|
27
|
-
#include <errno.h>
|
28
|
-
typedef pthread_mutex_t bloopsalock;
|
29
|
-
static inline void bloops_lock_init(bloopsalock *lock) {
|
30
|
-
pthread_mutex_init(lock, NULL);
|
31
|
-
}
|
32
|
-
static inline void bloops_lock_acquire(bloopsalock *lock) {
|
33
|
-
pthread_mutex_lock(lock);
|
34
|
-
}
|
35
|
-
static inline int bloops_lock_try_acquire(bloopsalock *lock) {
|
36
|
-
return !pthread_mutex_trylock(lock);
|
37
|
-
}
|
38
|
-
static inline void bloops_lock_release(bloopsalock *lock) {
|
39
|
-
pthread_mutex_unlock(lock);
|
40
|
-
}
|
41
|
-
static inline void bloops_lock_finalize(bloopsalock *lock) {
|
42
|
-
pthread_mutex_destroy(lock);
|
43
|
-
}
|
44
|
-
#endif
|
45
|
-
|
46
|
-
#endif
|
data/sounds/dart.blu
DELETED
data/sounds/error.blu
DELETED
data/sounds/ice.blu
DELETED
data/sounds/jump.blu
DELETED
data/sounds/pogo.blu
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
type square
|
2
|
-
volume 0.977
|
3
|
-
punch 0.190
|
4
|
-
sustain 0.165
|
5
|
-
slide 0.100
|
6
|
-
dslide 0.030
|
7
|
-
square 0.048
|
8
|
-
sweep -0.055
|
9
|
-
vibe 0.437
|
10
|
-
vspeed 0.310
|
11
|
-
lpf 0.355
|
12
|
-
resonance 0.185
|
13
|
-
hpf 0.205
|
14
|
-
hsweep 0.255
|
15
|
-
arp 0.677
|
16
|
-
aspeed 0.275
|
17
|
-
phase 0.200
|
18
|
-
psweep -0.565
|
19
|
-
repeat 0.500
|