Skip to content

Commit da43aab

Browse files
committed
finally got rid of all prefixes and done some simple Sound with callbacks
1 parent 0f879f5 commit da43aab

File tree

10 files changed

+251
-213
lines changed

10 files changed

+251
-213
lines changed

examples/play.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from sys import argv
33
from pyrilla import internal
4+
from time import sleep
45

6+
def finished(*args):
7+
print("finished")
8+
9+
go_on = False
510

611
def main():
712
if len(argv) != 2:
@@ -12,10 +17,18 @@ def main():
1217
else:
1318
filename = argv[1]
1419
ext = filename.rpartition('.')[2]
20+
1521
print("will load %s as %s" % (filename, ext))
22+
s = internal.Sound(filename, ext)
1623

17-
internal.play(filename, ext)
24+
s.play(on_finish=finished)
1825

26+
try:
27+
while True:
28+
internal.update()
29+
sleep(0.001)
30+
except KeyboardInterrupt:
31+
print("quiting")
1932

2033
if __name__ == "__main__":
2134
main()

examples/short.ogg

6.49 KB
Binary file not shown.

extensions/ga.pxd

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,202 +6,202 @@ cdef extern from "gorilla/ga.h":
66
int32 in_major, int32 in_minor, int32 in_rev
77
)
88

9-
cdef int32 format_sample "ga_format_sampleSize" (ga_Format* in_format)
9+
cdef int32 format_sample "ga_format_sampleSize" (Format* in_format)
1010

1111
cdef float32 format_toSeconds "ga_format_toSeconds" (
12-
ga_Format* in_format, int32 in_samples
12+
Format* in_format, int32 in_samples
1313
)
1414

1515
cdef int32 format_toSamples "ga_format_toSamples" (
16-
ga_Format* in_format, float32 in_seconds
16+
Format* in_format, float32 in_seconds
1717
)
1818

19-
cdef ga_Device* device_open "ga_device_open" (
19+
cdef Device* device_open "ga_device_open" (
2020
int32 in_type,
2121
int32 in_numBuffers,
2222
int32 in_numSamples,
23-
ga_Format* in_format
23+
Format* in_format
2424
)
2525

26-
cdef int32 device_check "ga_device_check" (ga_Device* in_device)
27-
cdef result device_queue "ga_device_queue" (ga_Device* in_device, void* in_buffer)
28-
cdef result device_close "ga_device_close" (ga_Device* in_device)
26+
cdef int32 device_check "ga_device_check" (Device* in_device)
27+
cdef result device_queue "ga_device_queue" (Device* in_device, void* in_buffer)
28+
cdef result device_close "ga_device_close" (Device* in_device)
2929

3030
cdef int32 data_source_read "ga_data_source_read" (
31-
ga_DataSource* in_dataSrc,
31+
DataSource* in_dataSrc,
3232
void* in_dst,
3333
int32 in_size,
3434
int32 in_count
3535
)
3636

3737
cdef int32 data_source_seek "ga_data_source_seek" (
38-
ga_DataSource* in_dataSrc,
38+
DataSource* in_dataSrc,
3939
int32 in_offset,
4040
int32 in_origin
4141
)
4242

43-
cdef int32 data_source_tell "ga_data_source_tell" (ga_DataSource* in_dataSrc)
44-
cdef int32 data_source_flags "ga_data_source_flags" (ga_DataSource* in_dataSrc)
45-
cdef void data_source_acquire "ga_data_source_acquire" (ga_DataSource* in_dataSrc)
46-
cdef void data_source_release "ga_data_source_release" (ga_DataSource* in_dataSrc)
43+
cdef int32 data_source_tell "ga_data_source_tell" (DataSource* in_dataSrc)
44+
cdef int32 data_source_flags "ga_data_source_flags" (DataSource* in_dataSrc)
45+
cdef void data_source_acquire "ga_data_source_acquire" (DataSource* in_dataSrc)
46+
cdef void data_source_release "ga_data_source_release" (DataSource* in_dataSrc)
4747

4848
cdef int32 sample_source_read "ga_sample_source_read" (
49-
ga_SampleSource* in_sampleSrc,
49+
SampleSource* in_sampleSrc,
5050
void* in_dst,
5151
int32 in_numSamples,
5252
tOnSeekFunc in_onSeekFunc,
5353
void* in_seekContext
5454
)
5555

56-
cdef int32 sample_source_end "ga_sample_source_end" (ga_SampleSource* in_sampleSrc)
56+
cdef int32 sample_source_end "ga_sample_source_end" (SampleSource* in_sampleSrc)
5757
cdef int32 sample_source_ready "ga_sample_source_ready" (
58-
ga_SampleSource* in_sampleSrc,
58+
SampleSource* in_sampleSrc,
5959
int32 in_numSamples
6060
)
6161

6262
cdef int32 sample_source_seek "ga_sample_source_seek" (
63-
ga_SampleSource* in_sampleSrc,
63+
SampleSource* in_sampleSrc,
6464
int32 in_sampleOffset
6565
)
6666

6767
cdef int32 sample_source_tell "ga_sample_source_tell" (
68-
ga_SampleSource* in_sampleSrc,
68+
SampleSource* in_sampleSrc,
6969
int32* out_totalSamples
7070
)
7171

72-
cdef int32 sample_source_flags "ga_sample_source_flags" (ga_SampleSource* in_sampleSrc)
72+
cdef int32 sample_source_flags "ga_sample_source_flags" (SampleSource* in_sampleSrc)
7373
cdef void sample_source_format "ga_sample_source_format" (
74-
ga_SampleSource* in_sampleSrc,
75-
ga_Format* out_format
74+
SampleSource* in_sampleSrc,
75+
Format* out_format
7676
)
7777

78-
cdef void sample_source_acquire "ga_sample_source_acquire" (ga_SampleSource* in_sampleSrc)
79-
cdef void sample_source_release "ga_sample_source_release" (ga_SampleSource* in_sampleSrc)
78+
cdef void sample_source_acquire "ga_sample_source_acquire" (SampleSource* in_sampleSrc)
79+
cdef void sample_source_release "ga_sample_source_release" (SampleSource* in_sampleSrc)
8080

81-
cdef ga_Memory* memory_create "ga_memory_create" (void* in_data, int32 in_size)
82-
cdef ga_Memory* memory_create_data_source "ga_memory_create_data_source" (ga_DataSource* in_dataSource)
83-
cdef int32 memory_size "ga_memory_size" (ga_Memory* in_mem)
81+
cdef Memory* memory_create "ga_memory_create" (void* in_data, int32 in_size)
82+
cdef Memory* memory_create_data_source "ga_memory_create_data_source" (DataSource* in_dataSource)
83+
cdef int32 memory_size "ga_memory_size" (Memory* in_mem)
8484

85-
cdef void* memory_data "ga_memory_data" (ga_Memory* in_mem)
85+
cdef void* memory_data "ga_memory_data" (Memory* in_mem)
8686

87-
cdef void memory_acquire "ga_memory_acquire" (ga_Memory* in_mem)
88-
cdef void memory_release "ga_memory_release" (ga_Memory* in_mem)
87+
cdef void memory_acquire "ga_memory_acquire" (Memory* in_mem)
88+
cdef void memory_release "ga_memory_release" (Memory* in_mem)
8989

90-
cdef ga_Sound* sound_create "ga_sound_create" (ga_Memory* in_memory, ga_Format* in_format)
91-
cdef ga_Sound* sound_create_sample_source "ga_sound_create_sample_source" (ga_SampleSource* in_sampleSrc)
92-
cdef void* sound_data "ga_sound_data" (ga_Sound* in_sound)
93-
cdef int32 sound_size "ga_sound_size" (ga_Sound* in_sound)
90+
cdef Sound* sound_create "ga_sound_create" (Memory* in_memory, Format* in_format)
91+
cdef Sound* sound_create_sample_source "ga_sound_create_sample_source" (SampleSource* in_sampleSrc)
92+
cdef void* sound_data "ga_sound_data" (Sound* in_sound)
93+
cdef int32 sound_size "ga_sound_size" (Sound* in_sound)
9494

95-
cdef int32 sound_numSamples "ga_sound_numSamples" (ga_Sound* in_sound)
96-
cdef void sound_format "ga_sound_format"(ga_Sound* in_sound, ga_Format* out_format)
97-
cdef void sound_acquire "ga_sound_acquire" (ga_Sound* in_sound)
98-
cdef void sound_release "ga_sound_release"(ga_Sound* in_sound)
95+
cdef int32 sound_numSamples "ga_sound_numSamples" (Sound* in_sound)
96+
cdef void sound_format "ga_sound_format"(Sound* in_sound, Format* out_format)
97+
cdef void sound_acquire "ga_sound_acquire" (Sound* in_sound)
98+
cdef void sound_release "ga_sound_release"(Sound* in_sound)
9999

100-
cdef ga_Mixer* mixer_create "ga_mixer_create" (ga_Format* in_format, int32 in_numSamples)
101-
cdef ga_Format* mixer_format "ga_mixer_format" (ga_Mixer* in_mixer)
102-
cdef int32 mixer_numSamples "ga_mixer_numSamples" (ga_Mixer* in_mixer)
103-
cdef result mixer_mix "ga_mixer_mix" (ga_Mixer* in_mixer, void* out_buffer)
100+
cdef Mixer* mixer_create "ga_mixer_create" (Format* in_format, int32 in_numSamples)
101+
cdef Format* mixer_format "ga_mixer_format" (Mixer* in_mixer)
102+
cdef int32 mixer_numSamples "ga_mixer_numSamples" (Mixer* in_mixer)
103+
cdef result mixer_mix "ga_mixer_mix" (Mixer* in_mixer, void* out_buffer)
104104

105-
cdef result mixer_dispatch "ga_mixer_dispatch" (ga_Mixer* in_mixer)
106-
cdef result mixer_destroy "ga_mixer_destroy" (ga_Mixer* in_mixer)
105+
cdef result mixer_dispatch "ga_mixer_dispatch" (Mixer* in_mixer)
106+
cdef result mixer_destroy "ga_mixer_destroy" (Mixer* in_mixer)
107107

108108

109-
cdef ga_Handle* handle_create "ga_handle_create" (ga_Mixer* in_mixer, ga_SampleSource* in_sampleSrc)
110-
cdef result handle_destroy "ga_handle_destroy" (ga_Handle* in_handle)
111-
cdef result handle_play "ga_handle_play" (ga_Handle* in_handle)
112-
cdef result handle_stop "ga_handle_stop" (ga_Handle* in_handle)
109+
cdef Handle* handle_create "ga_handle_create" (Mixer* in_mixer, SampleSource* in_sampleSrc)
110+
cdef result handle_destroy "ga_handle_destroy" (Handle* in_handle)
111+
cdef result handle_play "ga_handle_play" (Handle* in_handle)
112+
cdef result handle_stop "ga_handle_stop" (Handle* in_handle)
113113

114-
cdef int32 handle_playing "ga_handle_playing" (ga_Handle* in_handle)
115-
cdef int32 handle_stopped "ga_handle_stopped" (ga_Handle* in_handle)
116-
cdef int32 handle_finished "ga_handle_finished" (ga_Handle* in_handle)
117-
cdef int32 handle_destroyed "ga_handle_destroyed" (ga_Handle* in_handle)
114+
cdef int32 handle_playing "ga_handle_playing" (Handle* in_handle)
115+
cdef int32 handle_stopped "ga_handle_stopped" (Handle* in_handle)
116+
cdef int32 handle_finished "ga_handle_finished" (Handle* in_handle)
117+
cdef int32 handle_destroyed "ga_handle_destroyed" (Handle* in_handle)
118118

119119
cdef result handle_setCallback "ga_handle_setCallback" (
120-
ga_Handle* in_handle,
121-
ga_FinishCallback in_callback,
120+
Handle* in_handle,
121+
FinishCallback in_callback,
122122
void* in_context
123123
)
124124

125125
cdef result handle_setParamf "ga_handle_setParamf" (
126-
ga_Handle* in_handle,
126+
Handle* in_handle,
127127
int32 in_param,
128128
float32 in_value
129129
)
130130

131131
cdef result handle_getParamf "ga_handle_getParamf" (
132-
ga_Handle* in_handle,
132+
Handle* in_handle,
133133
int32 in_param,
134134
float32* out_value
135135
)
136136

137137
cdef result handle_setParami "ga_handle_setParami" (
138-
ga_Handle* in_handle,
138+
Handle* in_handle,
139139
int32 in_param,
140140
int32 in_value
141141
)
142142

143143
cdef result handle_getParami "ga_handle_getParami" (
144-
ga_Handle* in_handle,
144+
Handle* in_handle,
145145
int32 in_param,
146146
int32* out_value
147147
)
148148

149149
cdef result handle_seek "ga_handle_seek" (
150-
ga_Handle* in_handle,
150+
Handle* in_handle,
151151
int32 in_sampleOffset
152152
)
153153

154154
cdef int32 handle_tell "ga_handle_tell" (
155-
ga_Handle* in_handle,
155+
Handle* in_handle,
156156
int32 in_param
157157
)
158158

159159
cdef int32 handle_ready "ga_handle_ready" (
160-
ga_Handle* in_handle,
160+
Handle* in_handle,
161161
int32 in_numSamples
162162
)
163163

164164
cdef void handle_format "ga_handle_format" (
165-
ga_Handle* in_handle,
166-
ga_Format* out_format
165+
Handle* in_handle,
166+
Format* out_format
167167
)
168168

169-
cdef ga_StreamManager* stream_manager_create "ga_stream_manager_create" ()
170-
cdef void stream_manager_buffer "ga_stream_manager_buffer" (ga_StreamManager* in_mgr)
171-
cdef void stream_manager_destroy "ga_stream_manager_destroy" (ga_StreamManager* in_mgr)
169+
cdef StreamManager* stream_manager_create "ga_stream_manager_create" ()
170+
cdef void stream_manager_buffer "ga_stream_manager_buffer" (StreamManager* in_mgr)
171+
cdef void stream_manager_destroy "ga_stream_manager_destroy" (StreamManager* in_mgr)
172172

173-
cdef ga_BufferedStream* stream_create "ga_stream_create" (
174-
ga_StreamManager* in_mgr,
175-
ga_SampleSource* in_sampleSrc,
173+
cdef BufferedStream* stream_create "ga_stream_create" (
174+
StreamManager* in_mgr,
175+
SampleSource* in_sampleSrc,
176176
int32 in_bufferSize
177177
)
178178

179179
cdef void stream_produce "ga_stream_produce" (
180-
ga_BufferedStream* in_stream
180+
BufferedStream* in_stream
181181
)
182182
cdef int32 stream_read "ga_stream_read" (
183-
ga_BufferedStream* in_stream,
183+
BufferedStream* in_stream,
184184
void* in_dst,
185185
int32 in_numSamples
186186
)
187187

188-
cdef int32 stream_end "ga_stream_end" (ga_BufferedStream* in_stream)
188+
cdef int32 stream_end "ga_stream_end" (BufferedStream* in_stream)
189189

190190
cdef int32 stream_ready "ga_stream_ready" (
191-
ga_BufferedStream* in_stream,
191+
BufferedStream* in_stream,
192192
int32 in_numSamples
193193
)
194194

195195
cdef int32 stream_seek "ga_stream_seek" (
196-
ga_BufferedStream* in_stream,
196+
BufferedStream* in_stream,
197197
int32 in_sampleOffset
198198
)
199199

200200
cdef int32 stream_tell "ga_stream_tell" (
201-
ga_BufferedStream* in_stream,
201+
BufferedStream* in_stream,
202202
int32* out_totalSamples
203203
)
204-
cdef int32 stream_flags "ga_stream_flags" (ga_BufferedStream* in_stream)
204+
cdef int32 stream_flags "ga_stream_flags" (BufferedStream* in_stream)
205205

206-
cdef void stream_acquire "ga_stream_acquire" (ga_BufferedStream* in_stream)
207-
cdef void stream_release "ga_stream_release" (ga_BufferedStream* in_stream)
206+
cdef void stream_acquire "ga_stream_acquire" (BufferedStream* in_stream)
207+
cdef void stream_release "ga_stream_release" (BufferedStream* in_stream)

0 commit comments

Comments
 (0)