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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ff74b87bd6668a2022c0730d5bb9597602694866ea05c08e90d9a9ac1e1248d
4
- data.tar.gz: 142d1ca8c651a8ab51cac75f70d426daf369d8e09e1b37b88e16e323a044bbe3
3
+ metadata.gz: 64a48d1c26dbc98e6b0231d7ccc72455ad5ee487141ce0dd9eb170ee43b47976
4
+ data.tar.gz: 7962a4fd132fa2fe79e1f33eb87b7c06595a6cf8405850dd983b45ba9f2c596b
5
5
  SHA512:
6
- metadata.gz: 4f419874ed73b34b3810d7fd93e97b6184496a0841b34281d2122370b61ec3201d47df2caccf8de5d18cea85655fd471099aab432a51597edbb013a85408cd54
7
- data.tar.gz: 28785f40b88bc23e31f2a449590802bb3c800f049dcd59ddba1f1121525e8103c3879c6bd3b53d0dd85b7b46775606d4569ffaf96754474934fa1d9d2f70fd77
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
@@ -49,6 +49,14 @@ module DummyAudio
49
49
  nil
50
50
  end
51
51
 
52
+ def self.set_pan(channel, pan)
53
+ nil
54
+ end
55
+
56
+ def self.seek(channel, seconds)
57
+ nil
58
+ end
59
+
52
60
  def self.set_looping(channel, looping)
53
61
  nil
54
62
  end
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: native_audio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Hatfull