native_audio 0.5.4 → 0.5.6
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.
- checksums.yaml +4 -4
- data/ext/audio/audio.c +33 -0
- data/lib/dummy_audio.rb +8 -0
- data/lib/native_audio.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64a48d1c26dbc98e6b0231d7ccc72455ad5ee487141ce0dd9eb170ee43b47976
|
|
4
|
+
data.tar.gz: 7962a4fd132fa2fe79e1f33eb87b7c06595a6cf8405850dd983b45ba9f2c596b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3098316f693c450a8f0300f157964a7ddce5f9f1320bafd0447ce1e8707a568e48604fb2c10d5bcb8e1349dc7dca7db419757b9dc91c69f29b6e24e64103fd14
|
|
7
|
+
data.tar.gz: 96ae5fd5579fb9132f2a428688453cc9885cd5bfc86edbe3a546e1ed50e8f06ec4fbd251dbfb6dfb58b1e484b7e51294b47bec4812c9938b3b62160425111e3f
|
data/ext/audio/audio.c
CHANGED
|
@@ -232,6 +232,9 @@ VALUE audio_play(VALUE self, VALUE channel_id, VALUE clip)
|
|
|
232
232
|
|
|
233
233
|
cleanup_finished_channels();
|
|
234
234
|
|
|
235
|
+
// Cancel any pending drain timer for this channel
|
|
236
|
+
drain_until_frame[channel] = 0;
|
|
237
|
+
|
|
235
238
|
// Clean up existing resources on this channel
|
|
236
239
|
if (channels[channel] != NULL) {
|
|
237
240
|
ma_sound_stop(channels[channel]);
|
|
@@ -422,6 +425,34 @@ VALUE audio_set_pos(VALUE self, VALUE channel_id, VALUE angle, VALUE distance)
|
|
|
422
425
|
return Qnil;
|
|
423
426
|
}
|
|
424
427
|
|
|
428
|
+
VALUE audio_set_pan(VALUE self, VALUE channel_id, VALUE pan)
|
|
429
|
+
{
|
|
430
|
+
int channel = NUM2INT(channel_id);
|
|
431
|
+
float p = (float)NUM2DBL(pan);
|
|
432
|
+
|
|
433
|
+
if (channel < 0 || channel >= MAX_CHANNELS || channels[channel] == NULL) {
|
|
434
|
+
return Qnil;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
ma_sound_set_pan(channels[channel], p);
|
|
438
|
+
|
|
439
|
+
return Qnil;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
VALUE audio_seek(VALUE self, VALUE channel_id, VALUE seconds)
|
|
443
|
+
{
|
|
444
|
+
int channel = NUM2INT(channel_id);
|
|
445
|
+
float s = (float)NUM2DBL(seconds);
|
|
446
|
+
|
|
447
|
+
if (channel < 0 || channel >= MAX_CHANNELS || channels[channel] == NULL) {
|
|
448
|
+
return Qnil;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
ma_sound_seek_to_second(channels[channel], s);
|
|
452
|
+
|
|
453
|
+
return Qnil;
|
|
454
|
+
}
|
|
455
|
+
|
|
425
456
|
VALUE audio_set_looping(VALUE self, VALUE channel_id, VALUE looping)
|
|
426
457
|
{
|
|
427
458
|
int channel = NUM2INT(channel_id);
|
|
@@ -606,7 +637,9 @@ void Init_audio(void)
|
|
|
606
637
|
rb_define_singleton_method(mAudio, "set_volume", audio_set_volume, 2);
|
|
607
638
|
rb_define_singleton_method(mAudio, "set_pitch", audio_set_pitch, 2);
|
|
608
639
|
rb_define_singleton_method(mAudio, "set_pos", audio_set_pos, 3);
|
|
640
|
+
rb_define_singleton_method(mAudio, "set_pan", audio_set_pan, 2);
|
|
609
641
|
rb_define_singleton_method(mAudio, "set_looping", audio_set_looping, 2);
|
|
642
|
+
rb_define_singleton_method(mAudio, "seek", audio_seek, 2);
|
|
610
643
|
|
|
611
644
|
// Delay taps
|
|
612
645
|
rb_define_singleton_method(mAudio, "add_delay_tap", audio_add_delay_tap, 3);
|
data/lib/dummy_audio.rb
CHANGED
data/lib/native_audio.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative './audio'
|
|
4
4
|
require_relative './dummy_audio'
|
|
5
5
|
|
|
6
|
+
puts "[NativeAudio] Loading local development version"
|
|
6
7
|
Audio.init unless ENV['DUMMY_AUDIO_BACKEND'] == 'true'
|
|
7
8
|
|
|
8
9
|
module NativeAudio
|
|
@@ -83,6 +84,15 @@ module NativeAudio
|
|
|
83
84
|
NativeAudio.audio_driver.set_pos(@channel, angle, distance)
|
|
84
85
|
end
|
|
85
86
|
|
|
87
|
+
def set_pan(pan)
|
|
88
|
+
@params[:pan] = pan
|
|
89
|
+
NativeAudio.audio_driver.set_pan(@channel, pan)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def seek(seconds)
|
|
93
|
+
NativeAudio.audio_driver.seek(@channel, seconds)
|
|
94
|
+
end
|
|
95
|
+
|
|
86
96
|
def set_volume(volume)
|
|
87
97
|
@params[:volume] = volume
|
|
88
98
|
NativeAudio.audio_driver.set_volume(@channel, volume)
|
|
@@ -133,6 +143,7 @@ module NativeAudio
|
|
|
133
143
|
NativeAudio.audio_driver.set_volume(@channel, @params[:volume]) if @params.key?(:volume)
|
|
134
144
|
NativeAudio.audio_driver.set_pitch(@channel, @params[:pitch]) if @params.key?(:pitch)
|
|
135
145
|
NativeAudio.audio_driver.set_looping(@channel, @params[:looping]) if @params.key?(:looping)
|
|
146
|
+
NativeAudio.audio_driver.set_pan(@channel, @params[:pan]) if @params.key?(:pan)
|
|
136
147
|
NativeAudio.audio_driver.set_pos(@channel, *@params[:pos]) if @params.key?(:pos)
|
|
137
148
|
|
|
138
149
|
if @params.key?(:reverb)
|