bloops 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +27 -0
- data/Makefile +60 -0
- data/README +172 -0
- data/c/bloopsaphone-internal.h +46 -0
- data/c/bloopsaphone.c +596 -0
- data/c/bloopsaphone.h +154 -0
- data/c/bloopsawhat.c +38 -0
- data/c/notation.c +1656 -0
- data/c/notation.rl +549 -0
- data/ext/ruby/extconf.rb +15 -0
- data/ext/ruby/rubyext.c +332 -0
- data/ext/ruby/test.rb +41 -0
- data/ext/ruby/test_load.rb +25 -0
- data/ext/ruby/tune_cheeky_drat.rb +210 -0
- data/ext/ruby/tune_warp.rb +408 -0
- data/misc/Makefile-dll +91 -0
- data/sounds/dart.blu +10 -0
- data/sounds/error.blu +13 -0
- data/sounds/ice.blu +5 -0
- data/sounds/jump.blu +8 -0
- data/sounds/pogo.blu +19 -0
- data/sounds/stun.blu +6 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cd9f25401e9862ac0cefccbc8db376e505b4a87211f79fe29d604cfda106b98
|
4
|
+
data.tar.gz: ca5d8575c212f385ab0d6bd80c61b6265a7d81b8f1d353643a800e12c844e8c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b72958048821906c0aad1fb8989d833799b09a7c8ab2f03b72add6a6eefc28e6750bddb79fcc38048f1a219444f1b2b2d882ba4ecb753fb6035575fb10894a1
|
7
|
+
data.tar.gz: 395c456eecfb898e86a01cdc55968e73f37dc728b634f6639872e33f89558ee51595286885aafe394c98bcb18a621f79d9d7a389d81a27b48f128686b6e88d19
|
data/COPYING
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
:$: BLOOPSAPHONE :$:
|
3
|
+
Copyright (c) 2009 why the lucky stiff
|
4
|
+
Based on sfxr (c) 2007 Tomas Pettersson
|
5
|
+
(Also released under the MIT license)
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person
|
8
|
+
obtaining a copy of this software and associated documentation
|
9
|
+
files (the "Software"), to deal in the Software without restriction,
|
10
|
+
including without limitation the rights to use, copy, modify, merge,
|
11
|
+
publish, distribute, sublicense, and/or sell copies of the Software,
|
12
|
+
and to permit persons to whom the Software is furnished to do so,
|
13
|
+
subject to the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
19
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
20
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
21
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
22
|
+
SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
23
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
24
|
+
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
25
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
data/Makefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
SRC = c/bloopsaphone.c c/notation.c
|
2
|
+
OBJ = ${SRC:.c=.o}
|
3
|
+
|
4
|
+
PREFIX = /usr/local
|
5
|
+
CC = gcc
|
6
|
+
AR = ar
|
7
|
+
ARFLAGS = cr
|
8
|
+
CFLAGS ?= -Wall
|
9
|
+
DEBUG ?= 0
|
10
|
+
ECHO = /bin/echo
|
11
|
+
INCS = -Ic
|
12
|
+
LDFLAGS ?=
|
13
|
+
LIBS = -lm -lportaudio
|
14
|
+
RAGEL = ragel
|
15
|
+
|
16
|
+
RAGELV = `${RAGEL} -v | sed "/ version /!d; s/.* version //; s/ .*//"`
|
17
|
+
|
18
|
+
all: bloopsaphone
|
19
|
+
|
20
|
+
rebuild: clean bloopsaphone
|
21
|
+
|
22
|
+
bloopsaphone: bloopsawhat bloopsalib
|
23
|
+
|
24
|
+
bloopsawhat: ${OBJ} c/bloopsawhat.o
|
25
|
+
@${ECHO} LINK bloopsawhat
|
26
|
+
@${CC} ${CFLAGS} ${OBJ} c/bloopsawhat.o ${LDFLAGS} ${LIBS} -o bloopsawhat
|
27
|
+
|
28
|
+
bloopsalib: ${OBJ}
|
29
|
+
@${ECHO} LINK bloopsalib
|
30
|
+
@${AR} ${ARFLAGS} libbloopsaphone.a ${OBJ}
|
31
|
+
|
32
|
+
c/notation.c: c/notation.rl
|
33
|
+
@if [ "${RAGELV}" != "6.3" ]; then \
|
34
|
+
if [ "${RAGELV}" != "6.2" ]; then \
|
35
|
+
${ECHO} "** bloopsaphone may not work with ragel ${RAGELV}! try version 6.2 or 6.3."; \
|
36
|
+
fi; \
|
37
|
+
fi
|
38
|
+
@${ECHO} RAGEL c/notation.rl
|
39
|
+
@${RAGEL} c/notation.rl -C -o $@
|
40
|
+
|
41
|
+
%.o: %.c
|
42
|
+
@${ECHO} CC $<
|
43
|
+
@${CC} -c ${CFLAGS} ${INCS} -o $@ $<
|
44
|
+
|
45
|
+
clean:
|
46
|
+
@${ECHO} cleaning
|
47
|
+
@rm -f ${OBJ}
|
48
|
+
@rm -f c/notation.c c/*.o
|
49
|
+
@rm -f bloopsawhat libbloopsaphone.a bloopsaphone.so
|
50
|
+
@cd ext/ruby && make distclean || true
|
51
|
+
|
52
|
+
ruby: c/notation.c c/bloopsaphone.c
|
53
|
+
@${ECHO} RUBY extconf.rb
|
54
|
+
@cd ext/ruby && CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ruby extconf.rb && make
|
55
|
+
@${ECHO} ""
|
56
|
+
@${ECHO} "To test: cd ext/ruby"
|
57
|
+
@${ECHO} "Then: ruby test.rb"
|
58
|
+
@${ECHO} ""
|
59
|
+
|
60
|
+
.PHONY: all bloopsaphone clean rebuild ruby
|
data/README
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
|
2
|
+
|~~ |~~
|
3
|
+
| |
|
4
|
+
:$: bloopsaphone :$:
|
5
|
+
`''''''''''''''''`
|
6
|
+
|
7
|
+
for writing chiptune-style songs
|
8
|
+
in c or ruby. you know: the sounds
|
9
|
+
of ataris, gameboys and the like.
|
10
|
+
|
11
|
+
~
|
12
|
+
|
13
|
+
-$- ABOUT
|
14
|
+
|
15
|
+
this is a small c library for sending
|
16
|
+
chiptunes through portaudio, which is
|
17
|
+
a rather light cross-platform audio lib.
|
18
|
+
<http://www.portaudio.com/>
|
19
|
+
|
20
|
+
right now i'm only including ruby
|
21
|
+
bindings. you are welcome to contribute
|
22
|
+
code to hook up to other languages,
|
23
|
+
though.
|
24
|
+
|
25
|
+
i wrote this for h-ety h.
|
26
|
+
<http://hacketyhack.net/>
|
27
|
+
|
28
|
+
i don't have binaries ready for this yet,
|
29
|
+
so if you're on windows or os x, you may
|
30
|
+
have to wait until HH comes out at ART
|
31
|
+
AND CODE. the tribulations you face.
|
32
|
+
|
33
|
+
~
|
34
|
+
|
35
|
+
-$- THE BLOOPSAPHONE THEME SONG
|
36
|
+
(in ruby)
|
37
|
+
|
38
|
+
require 'bloops'
|
39
|
+
|
40
|
+
# the bloops o' phone
|
41
|
+
b = Bloops.new
|
42
|
+
b.tempo = 320
|
43
|
+
|
44
|
+
# melodious
|
45
|
+
s1 = b.sound Bloops::SQUARE
|
46
|
+
s1.punch = 0.5
|
47
|
+
s1.sustain = 0.4
|
48
|
+
s1.decay = 0.2
|
49
|
+
s1.arp = 0.4
|
50
|
+
s1.aspeed = 0.6
|
51
|
+
s1.repeat = 0.6
|
52
|
+
s1.phase = 0.2
|
53
|
+
s1.psweep = 0.2
|
54
|
+
|
55
|
+
# beats
|
56
|
+
s2 = b.sound Bloops::NOISE
|
57
|
+
s2.punch = 0.5
|
58
|
+
s2.sustain = 0.2
|
59
|
+
s2.decay = 0.4
|
60
|
+
s2.slide = -0.4
|
61
|
+
s2.phase = 0.2
|
62
|
+
s2.psweep = 0.2
|
63
|
+
|
64
|
+
# the tracks
|
65
|
+
b.tune s1, "f#5 c6 e4 b6 g5 d6 4 f#5 e5 c5 b6 c6 d6 4 "
|
66
|
+
b.tune s2, "4 c6 4 b5 4 4 e4 4 c6 4 b5 4 4 e4"
|
67
|
+
|
68
|
+
# and away we go
|
69
|
+
b.play
|
70
|
+
sleep 1 while !b.stopped?
|
71
|
+
|
72
|
+
~
|
73
|
+
|
74
|
+
-$- BUILDING FOR RUBY
|
75
|
+
|
76
|
+
If Ruby is in your path and PortAudio 1.9
|
77
|
+
or greater is installed:
|
78
|
+
|
79
|
+
make ruby
|
80
|
+
|
81
|
+
To install PortAudio 1.9 under Ubuntu:
|
82
|
+
|
83
|
+
aptitude install portaudio19-dev
|
84
|
+
|
85
|
+
To build from source isn't too bad.
|
86
|
+
Download PortAudio 1.9 and build it.
|
87
|
+
<http://www.portaudio.com/archives/pa_stable_v19_20071207.tar.gz>
|
88
|
+
|
89
|
+
Like this:
|
90
|
+
|
91
|
+
$ tar xzvf pa_stable_v19_20071207.tar.gz
|
92
|
+
$ cd portaudio
|
93
|
+
$ ./configure
|
94
|
+
$ make
|
95
|
+
$ sudo make install
|
96
|
+
|
97
|
+
Then go back to Bloopsaphone and do
|
98
|
+
a `make ruby`.
|
99
|
+
|
100
|
+
~
|
101
|
+
|
102
|
+
-$- THE IDEALS,
|
103
|
+
|
104
|
+
-1- ASYNCHRONOUS.
|
105
|
+
You send it a song and it plays in
|
106
|
+
the background. You'll get an event
|
107
|
+
when it finishes.
|
108
|
+
|
109
|
+
-2- SMALL.
|
110
|
+
This is just a toy, I don't want it
|
111
|
+
to be very big and comprehensive.
|
112
|
+
Just to play little tunes with a
|
113
|
+
nostalgic arcade sound rather than
|
114
|
+
the CASIO-stylings of most MIDI.
|
115
|
+
|
116
|
+
-3- CUSTOM NOTATION.
|
117
|
+
Someone told me about Nokring, iMelody,
|
118
|
+
numbered musical notation and I did
|
119
|
+
some reading. They're little languages
|
120
|
+
for texting yourself a ringtone.
|
121
|
+
|
122
|
+
<http://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language>
|
123
|
+
<http://homepage.mac.com/alvinmok/ericsson/emelody.html>
|
124
|
+
|
125
|
+
Bloopsaphone uses a variation on RTTTL.
|
126
|
+
|
127
|
+
Instead of commas, I use whitespace.
|
128
|
+
A rest is simply a number. A plus sign
|
129
|
+
moves everything up an octave. A minus
|
130
|
+
down an octave.
|
131
|
+
|
132
|
+
The Simpsons' Theme, for instance, would be:
|
133
|
+
|
134
|
+
32 + C E F# 8:A G E C - 8:A 8:F# 8:F# 8:F# 2:G
|
135
|
+
|
136
|
+
Which translates into:
|
137
|
+
|
138
|
+
* a 1/32nd note rest.
|
139
|
+
* change one octave up.
|
140
|
+
* C quarter note.
|
141
|
+
* E quarter note.
|
142
|
+
* F# quarter note.
|
143
|
+
* A eighth note.
|
144
|
+
* G quarter.
|
145
|
+
* E quarter.
|
146
|
+
* C one-quarter note.
|
147
|
+
* change one octave down.
|
148
|
+
* A eighth.
|
149
|
+
* Three F# eighths.
|
150
|
+
* G half note.
|
151
|
+
|
152
|
+
The colons are optional. They are there because you
|
153
|
+
can place an octave number after each note. Somehow
|
154
|
+
"8B6" (an eighth note of B at the sixth octave) looks
|
155
|
+
more confusing than "8:B6". I guess I figured that
|
156
|
+
the timing "8" is conceptually separate from the
|
157
|
+
actual tone "B6", even though they both comprise
|
158
|
+
the note itself.
|
159
|
+
|
160
|
+
-4- SERIALIZE SOUNDS.
|
161
|
+
To accomodate passing instruments between
|
162
|
+
ruby and c, bloopsaphone comes with a tiny
|
163
|
+
file format for describing sounds.
|
164
|
+
|
165
|
+
You can find examples of these in the sounds/
|
166
|
+
folder in this distro. Possible sound types
|
167
|
+
are 'square', 'sawtooth', 'sine' and 'noise'.
|
168
|
+
All other settings go from 0.0 to 1.0.
|
169
|
+
|
170
|
+
The 'freq' setting is only used if the sound
|
171
|
+
is played without a tune.
|
172
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
//
|
2
|
+
// threads.h - threaded garments for the bloopsaphone
|
3
|
+
//
|
4
|
+
#ifndef BLOOPSAPHONE_INTERNAL_H
|
5
|
+
#define BLOOPSAPHONE_INTERNAL_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
|