sfml3-rb 0.2.2 → 0.3.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.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +67 -16
- data/README.md +123 -32
- data/TODO.md +18 -11
- data/ext/audio/audio_enums.c +58 -20
- data/ext/audio/listener.c +89 -6
- data/ext/audio/music.c +212 -5
- data/ext/audio/sound.c +218 -9
- data/ext/audio/sound_buffer.c +197 -47
- data/ext/audio/sound_buffer_recorder.c +90 -18
- data/ext/audio/sound_recorder.c +188 -58
- data/ext/audio/sound_source_cone.c +127 -33
- data/ext/audio/sound_stream.c +204 -21
- data/ext/core/exceptions.c +10 -8
- data/ext/core/unicode.c +12 -2
- data/ext/ext.c +8 -0
- data/ext/graphics/blend_mode.c +218 -60
- data/ext/graphics/circle.c +300 -16
- data/ext/graphics/color.c +253 -94
- data/ext/graphics/drawable.c +16 -4
- data/ext/graphics/font.c +144 -25
- data/ext/graphics/glyph.c +38 -8
- data/ext/graphics/image.c +205 -41
- data/ext/graphics/polygon.c +317 -30
- data/ext/graphics/rect.c +225 -60
- data/ext/graphics/rectangle.c +307 -35
- data/ext/graphics/render_state.c +124 -12
- data/ext/graphics/render_texture.c +191 -14
- data/ext/graphics/render_window.c +55 -0
- data/ext/graphics/render_window.h +10 -0
- data/ext/graphics/shader.c +289 -17
- data/ext/graphics/shape.c +265 -32
- data/ext/graphics/sprite.c +245 -30
- data/ext/graphics/stencil_mode.c +163 -46
- data/ext/graphics/target.c +121 -43
- data/ext/graphics/target.h +31 -17
- data/ext/graphics/text.c +339 -19
- data/ext/graphics/texture.c +291 -6
- data/ext/graphics/transform.c +178 -5
- data/ext/graphics/transformable.c +127 -12
- data/ext/graphics/vertex.c +98 -6
- data/ext/graphics/vertex_array.c +142 -21
- data/ext/graphics/vertex_buffer.c +154 -12
- data/ext/graphics/view.c +140 -6
- data/ext/network/ftp.c +278 -12
- data/ext/network/http.c +179 -44
- data/ext/network/ip_address.c +127 -35
- data/ext/network/network_enums.c +248 -141
- data/ext/network/packet.c +280 -41
- data/ext/network/socket_selector.c +98 -21
- data/ext/network/tcp_listener.c +82 -18
- data/ext/network/tcp_socket.c +135 -27
- data/ext/network/udp_socket.c +129 -28
- data/ext/ports.rb +7 -0
- data/ext/system/buffer.c +47 -16
- data/ext/system/clock.c +77 -12
- data/ext/system/input_stream.c +113 -51
- data/ext/system/sleep.c +10 -2
- data/ext/system/time.c +182 -40
- data/ext/system/vec2.c +166 -39
- data/ext/system/vec3.c +177 -39
- data/ext/window/clipboard.c +47 -17
- data/ext/window/context.c +66 -13
- data/ext/window/context_settings.c +132 -42
- data/ext/window/cursor.c +45 -9
- data/ext/window/event.c +164 -53
- data/ext/window/joystick.c +69 -3
- data/ext/window/keyboard.c +168 -116
- data/ext/window/mouse.c +64 -13
- data/ext/window/sensor.c +28 -2
- data/ext/window/touch.c +32 -12
- data/ext/window/video_mode.c +93 -31
- data/ext/window/vulkan.c +34 -6
- data/ext/window/window.c +228 -229
- data/ext/window/window.h +4 -4
- data/ext/window/window_base.c +251 -0
- data/ext/window/window_base.h +43 -0
- data/ext/window/window_base.inc +236 -0
- data/lib/sfml/version.rb +1 -1
- data/sig/audio/audio_enums.rbs +30 -0
- data/sig/audio/listener.rbs +16 -0
- data/sig/audio/music.rbs +56 -0
- data/sig/audio/sound.rbs +51 -0
- data/sig/audio/sound_buffer.rbs +17 -0
- data/sig/audio/sound_buffer_recorder.rbs +14 -0
- data/sig/audio/sound_recorder.rbs +17 -0
- data/sig/audio/sound_source_cone.rbs +14 -0
- data/sig/audio/sound_stream.rbs +51 -0
- data/sig/graphics/blend_mode.rbs +29 -0
- data/sig/graphics/circle.rbs +44 -0
- data/sig/graphics/color.rbs +39 -0
- data/sig/graphics/drawable.rbs +5 -0
- data/sig/graphics/font.rbs +20 -0
- data/sig/graphics/glyph.rbs +7 -0
- data/sig/graphics/image.rbs +22 -0
- data/sig/graphics/polygon.rbs +42 -0
- data/sig/graphics/rect.rbs +33 -0
- data/sig/graphics/rectangle.rbs +42 -0
- data/sig/graphics/render_state.rbs +21 -0
- data/sig/graphics/render_target.rbs +18 -0
- data/sig/graphics/render_texture.rbs +39 -0
- data/sig/graphics/render_window.rbs +7 -0
- data/sig/graphics/shader.rbs +39 -0
- data/sig/graphics/shape.rbs +38 -0
- data/sig/graphics/sprite.rbs +34 -0
- data/sig/graphics/stencil_mode.rbs +18 -0
- data/sig/graphics/target.rbs +8 -0
- data/sig/graphics/text.rbs +48 -0
- data/sig/graphics/texture.rbs +34 -0
- data/sig/graphics/transform.rbs +37 -0
- data/sig/graphics/transformable.rbs +25 -0
- data/sig/graphics/vertex.rbs +17 -0
- data/sig/graphics/vertex_array.rbs +17 -0
- data/sig/graphics/vertex_buffer.rbs +22 -0
- data/sig/graphics/view.rbs +23 -0
- data/sig/network/ftp.rbs +46 -0
- data/sig/network/http.rbs +27 -0
- data/sig/network/ip_address.rbs +22 -0
- data/sig/network/network_enums.rbs +95 -0
- data/sig/network/packet.rbs +40 -0
- data/sig/network/socket_selector.rbs +14 -0
- data/sig/network/tcp_listener.rbs +13 -0
- data/sig/network/tcp_socket.rbs +18 -0
- data/sig/network/udp_socket.rbs +17 -0
- data/sig/sfml/version.rbs +3 -0
- data/sig/system/buffer.rbs +11 -0
- data/sig/system/clock.rbs +13 -0
- data/sig/system/input_stream.rbs +7 -0
- data/sig/system/sleep.rbs +3 -0
- data/sig/system/time.rbs +28 -0
- data/sig/system/vec2.rbs +26 -0
- data/sig/system/vec3.rbs +27 -0
- data/sig/window/clipboard.rbs +8 -0
- data/sig/window/context.rbs +11 -0
- data/sig/window/context_settings.rbs +20 -0
- data/sig/window/cursor.rbs +6 -0
- data/sig/window/event.rbs +20 -0
- data/sig/window/joystick.rbs +15 -0
- data/sig/window/keyboard.rbs +10 -0
- data/sig/window/mouse.rbs +9 -0
- data/sig/window/sensor.rbs +8 -0
- data/sig/window/touch.rbs +6 -0
- data/sig/window/video_mode.rbs +16 -0
- data/sig/window/vulkan.rbs +7 -0
- data/sig/window/window.rbs +34 -0
- data/sig/window/window_base.rbs +33 -0
- metadata +76 -3
data/ext/audio/listener.c
CHANGED
|
@@ -5,68 +5,151 @@
|
|
|
5
5
|
#include "audio/sound_source_cone.h"
|
|
6
6
|
#include "system/vec3.h"
|
|
7
7
|
|
|
8
|
+
/* call-seq: global_volume -> Float
|
|
9
|
+
*
|
|
10
|
+
* Returns the global volume applied to every sound source in the scene.
|
|
11
|
+
*
|
|
12
|
+
* @return [Float] 0 to 100
|
|
13
|
+
*/
|
|
8
14
|
static VALUE Listener_global_volume(VALUE module) {
|
|
9
15
|
return DBL2NUM(sfListener_getGlobalVolume());
|
|
10
16
|
}
|
|
11
17
|
|
|
18
|
+
/* call-seq:
|
|
19
|
+
* global_volume=(value) -> Float
|
|
20
|
+
*
|
|
21
|
+
* Sets the global volume all sound sources are scaled by.
|
|
22
|
+
*
|
|
23
|
+
* @return [Float] +value+
|
|
24
|
+
*/
|
|
12
25
|
static VALUE Listener_set_global_volume(VALUE module, VALUE rb_value) {
|
|
13
|
-
sfListener_setGlobalVolume((float)
|
|
26
|
+
sfListener_setGlobalVolume((float)NUM2DBL(rb_value));
|
|
14
27
|
return rb_value;
|
|
15
28
|
}
|
|
16
29
|
|
|
30
|
+
/* call-seq: position -> Vector3
|
|
31
|
+
*
|
|
32
|
+
* Returns the listener's position in the 3D audio scene.
|
|
33
|
+
*
|
|
34
|
+
* @return [Vector3]
|
|
35
|
+
*/
|
|
17
36
|
static VALUE Listener_position(VALUE module) {
|
|
18
37
|
return vec3f_to_rb(sfListener_getPosition());
|
|
19
38
|
}
|
|
20
39
|
|
|
40
|
+
/* call-seq:
|
|
41
|
+
* position=(value) -> Vector3
|
|
42
|
+
*
|
|
43
|
+
* Sets the listener's position in the 3D audio scene.
|
|
44
|
+
*
|
|
45
|
+
* @return [Vector3] +value+
|
|
46
|
+
*/
|
|
21
47
|
static VALUE Listener_set_position(VALUE module, VALUE rb_value) {
|
|
22
48
|
sfListener_setPosition(vec3f_from_rb(rb_value));
|
|
23
49
|
return rb_value;
|
|
24
50
|
}
|
|
25
51
|
|
|
52
|
+
/* call-seq: direction -> Vector3
|
|
53
|
+
*
|
|
54
|
+
* Returns the direction the listener is facing, used for spatialization.
|
|
55
|
+
*
|
|
56
|
+
* @return [Vector3]
|
|
57
|
+
*/
|
|
26
58
|
static VALUE Listener_direction(VALUE module) {
|
|
27
59
|
return vec3f_to_rb(sfListener_getDirection());
|
|
28
60
|
}
|
|
29
61
|
|
|
62
|
+
/* call-seq:
|
|
63
|
+
* direction=(value) -> Vector3
|
|
64
|
+
*
|
|
65
|
+
* Sets the direction the listener is facing.
|
|
66
|
+
*
|
|
67
|
+
* @return [Vector3] +value+
|
|
68
|
+
*/
|
|
30
69
|
static VALUE Listener_set_direction(VALUE module, VALUE rb_value) {
|
|
31
70
|
sfListener_setDirection(vec3f_from_rb(rb_value));
|
|
32
71
|
return rb_value;
|
|
33
72
|
}
|
|
34
73
|
|
|
74
|
+
/* call-seq: velocity -> Vector3
|
|
75
|
+
*
|
|
76
|
+
* Returns the listener's velocity, used for Doppler calculations.
|
|
77
|
+
*
|
|
78
|
+
* @return [Vector3]
|
|
79
|
+
*/
|
|
35
80
|
static VALUE Listener_velocity(VALUE module) {
|
|
36
81
|
return vec3f_to_rb(sfListener_getVelocity());
|
|
37
82
|
}
|
|
38
83
|
|
|
84
|
+
/* call-seq:
|
|
85
|
+
* velocity=(value) -> Vector3
|
|
86
|
+
*
|
|
87
|
+
* Sets the listener's velocity for Doppler calculations.
|
|
88
|
+
*
|
|
89
|
+
* @return [Vector3] +value+
|
|
90
|
+
*/
|
|
39
91
|
static VALUE Listener_set_velocity(VALUE module, VALUE rb_value) {
|
|
40
92
|
sfListener_setVelocity(vec3f_from_rb(rb_value));
|
|
41
93
|
return rb_value;
|
|
42
94
|
}
|
|
43
95
|
|
|
96
|
+
/* call-seq: up_vector -> Vector3
|
|
97
|
+
*
|
|
98
|
+
* Returns the listener's up vector, defining its vertical orientation.
|
|
99
|
+
*
|
|
100
|
+
* @return [Vector3]
|
|
101
|
+
*/
|
|
44
102
|
static VALUE Listener_up_vector(VALUE module) {
|
|
45
103
|
return vec3f_to_rb(sfListener_getUpVector());
|
|
46
104
|
}
|
|
47
105
|
|
|
106
|
+
/* call-seq:
|
|
107
|
+
* up_vector=(value) -> Vector3
|
|
108
|
+
*
|
|
109
|
+
* Sets the listener's up vector, defining its vertical orientation.
|
|
110
|
+
*
|
|
111
|
+
* @return [Vector3] +value+
|
|
112
|
+
*/
|
|
48
113
|
static VALUE Listener_set_up_vector(VALUE module, VALUE rb_value) {
|
|
49
114
|
sfListener_setUpVector(vec3f_from_rb(rb_value));
|
|
50
115
|
return rb_value;
|
|
51
116
|
}
|
|
52
117
|
|
|
118
|
+
/* call-seq: cone -> SoundSourceCone
|
|
119
|
+
*
|
|
120
|
+
* Returns the listener's directional attenuation cone.
|
|
121
|
+
*
|
|
122
|
+
* @return [SoundSourceCone]
|
|
123
|
+
*/
|
|
53
124
|
static VALUE Listener_cone(VALUE module) {
|
|
54
125
|
sfListenerCone cone = sfListener_getCone();
|
|
55
126
|
|
|
56
|
-
return sound_source_cone_to_rb(
|
|
57
|
-
|
|
127
|
+
return sound_source_cone_to_rb(
|
|
128
|
+
(sfSoundSourceCone){cone.innerAngle, cone.outerAngle, cone.outerGain});
|
|
58
129
|
}
|
|
59
130
|
|
|
131
|
+
/* call-seq:
|
|
132
|
+
* cone=(value) -> SoundSourceCone
|
|
133
|
+
*
|
|
134
|
+
* Sets the listener's directional attenuation cone.
|
|
135
|
+
*
|
|
136
|
+
* @return [SoundSourceCone] +value+
|
|
137
|
+
*/
|
|
60
138
|
static VALUE Listener_set_cone(VALUE module, VALUE rb_value) {
|
|
61
139
|
sfSoundSourceCone cone = sound_source_cone_from_rb(rb_value);
|
|
62
140
|
|
|
63
|
-
sfListener_setCone((sfListenerCone)
|
|
141
|
+
sfListener_setCone((sfListenerCone){cone.innerAngle, cone.outerAngle, cone.outerGain});
|
|
64
142
|
|
|
65
143
|
return rb_value;
|
|
66
144
|
}
|
|
67
145
|
|
|
68
|
-
|
|
69
|
-
|
|
146
|
+
/* Document-module: SFML::Listener
|
|
147
|
+
* Module functions controlling the single global audio listener: its
|
|
148
|
+
* position, orientation and volume, against which every SoundSource's
|
|
149
|
+
* spatialization is computed.
|
|
150
|
+
*/
|
|
151
|
+
void Init_Listener(VALUE rb_mSFML) {
|
|
152
|
+
VALUE rb_mListener = rb_define_module_under(rb_mSFML, "Listener");
|
|
70
153
|
|
|
71
154
|
rb_define_module_function(rb_mListener, "global_volume", Listener_global_volume, 0);
|
|
72
155
|
rb_define_module_function(rb_mListener, "global_volume=", Listener_set_global_volume, 1);
|
data/ext/audio/music.c
CHANGED
|
@@ -40,16 +40,23 @@ static void* Music_destroy_without_gvl(void* handle) {
|
|
|
40
40
|
static void Music_free(void* ptr) {
|
|
41
41
|
Music* music = ptr;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/* Destroy (which blocks until CSFML guarantees no in-flight audio-thread
|
|
44
|
+
callback still references this source) before releasing the effect
|
|
45
|
+
slot, not after -- see the matching comment in sound.c's Sound_free. */
|
|
44
46
|
rb_thread_call_without_gvl(Music_destroy_without_gvl, music->source.handle, RUBY_UBF_IO, NULL);
|
|
47
|
+
effect_processor_release(music->source.effect_slot);
|
|
45
48
|
rb_gc_unregister_address(&music->rb_stream);
|
|
46
49
|
free(music);
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
/* Deliberately no RUBY_TYPED_FREE_IMMEDIATELY: Music_free releases the GVL for
|
|
53
|
+
sfMusic_destroy, and freeing during GC (which the flag requests) would let
|
|
54
|
+
another thread allocate while GC is mid-cycle, which Ruby aborts on as
|
|
55
|
+
"object allocation during garbage collection phase". Deferred finalization
|
|
56
|
+
runs the same free with the GVL held and no GC in progress. */
|
|
49
57
|
static const rb_data_type_t Music_data_type = {
|
|
50
58
|
.wrap_struct_name = "SFML::Music",
|
|
51
|
-
.function = {.dmark = Music_mark, .dfree = Music_free, .dsize = NULL}
|
|
52
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY};
|
|
59
|
+
.function = {.dmark = Music_mark, .dfree = Music_free, .dsize = NULL}};
|
|
53
60
|
|
|
54
61
|
static VALUE Music_wrap(VALUE klass, sfMusic* handle, VALUE rb_stream) {
|
|
55
62
|
Music* ptr;
|
|
@@ -68,10 +75,26 @@ static VALUE Music_wrap(VALUE klass, sfMusic* handle, VALUE rb_stream) {
|
|
|
68
75
|
return TypedData_Wrap_Struct(klass, &Music_data_type, ptr);
|
|
69
76
|
}
|
|
70
77
|
|
|
78
|
+
/* call-seq:
|
|
79
|
+
* Music.from_file(path) -> Music
|
|
80
|
+
*
|
|
81
|
+
* Creates a music stream that reads from an audio file.
|
|
82
|
+
*
|
|
83
|
+
* @return [Music]
|
|
84
|
+
* @raise [RuntimeError] if the file cannot be opened or decoded
|
|
85
|
+
*/
|
|
71
86
|
static VALUE Music_from_file(VALUE klass, VALUE rb_path) {
|
|
72
87
|
return Music_wrap(klass, sfMusic_createFromFile(StringValueCStr(rb_path)), Qnil);
|
|
73
88
|
}
|
|
74
89
|
|
|
90
|
+
/* call-seq:
|
|
91
|
+
* Music.from_memory(data) -> Music
|
|
92
|
+
*
|
|
93
|
+
* Creates a music stream that reads from audio held in a String.
|
|
94
|
+
*
|
|
95
|
+
* @return [Music]
|
|
96
|
+
* @raise [RuntimeError] if +data+ cannot be decoded
|
|
97
|
+
*/
|
|
75
98
|
static VALUE Music_from_memory(VALUE klass, VALUE rb_data) {
|
|
76
99
|
StringValue(rb_data);
|
|
77
100
|
|
|
@@ -79,6 +102,14 @@ static VALUE Music_from_memory(VALUE klass, VALUE rb_data) {
|
|
|
79
102
|
klass, sfMusic_createFromMemory(RSTRING_PTR(rb_data), (size_t)RSTRING_LEN(rb_data)), Qnil);
|
|
80
103
|
}
|
|
81
104
|
|
|
105
|
+
/* call-seq:
|
|
106
|
+
* Music.from_stream(stream) -> Music
|
|
107
|
+
*
|
|
108
|
+
* Creates a music stream that reads from a custom InputStream.
|
|
109
|
+
*
|
|
110
|
+
* @return [Music]
|
|
111
|
+
* @raise [RuntimeError] if the stream cannot be decoded
|
|
112
|
+
*/
|
|
82
113
|
static VALUE Music_from_stream(VALUE klass, VALUE rb_stream) {
|
|
83
114
|
VALUE holder = Qnil;
|
|
84
115
|
sfInputStream* stream = input_stream_from_rb(rb_stream, &holder);
|
|
@@ -86,18 +117,43 @@ static VALUE Music_from_stream(VALUE klass, VALUE rb_stream) {
|
|
|
86
117
|
return Music_wrap(klass, sfMusic_createFromStream(stream), holder);
|
|
87
118
|
}
|
|
88
119
|
|
|
120
|
+
/* call-seq: duration -> Time
|
|
121
|
+
*
|
|
122
|
+
* Returns the total duration of the music.
|
|
123
|
+
*
|
|
124
|
+
* @return [Time] total duration of the music
|
|
125
|
+
*/
|
|
89
126
|
static VALUE Music_duration(VALUE self) {
|
|
90
127
|
return time_to_rb(sfMusic_getDuration(Get_Music_Struct(self)));
|
|
91
128
|
}
|
|
92
129
|
|
|
130
|
+
/* call-seq: channel_count -> Integer
|
|
131
|
+
*
|
|
132
|
+
* Returns the number of audio channels in the music.
|
|
133
|
+
*
|
|
134
|
+
* @return [Integer]
|
|
135
|
+
*/
|
|
93
136
|
static VALUE Music_channel_count(VALUE self) {
|
|
94
137
|
return UINT2NUM(sfMusic_getChannelCount(Get_Music_Struct(self)));
|
|
95
138
|
}
|
|
96
139
|
|
|
140
|
+
/* call-seq: sample_rate -> Integer
|
|
141
|
+
*
|
|
142
|
+
* Returns the music's sample rate in samples per second.
|
|
143
|
+
*
|
|
144
|
+
* @return [Integer]
|
|
145
|
+
*/
|
|
97
146
|
static VALUE Music_sample_rate(VALUE self) {
|
|
98
147
|
return UINT2NUM(sfMusic_getSampleRate(Get_Music_Struct(self)));
|
|
99
148
|
}
|
|
100
149
|
|
|
150
|
+
/* call-seq: channel_map -> Array<Symbol>
|
|
151
|
+
*
|
|
152
|
+
* Returns the channel layout of the music.
|
|
153
|
+
*
|
|
154
|
+
* @return [Array<Symbol>] one entry per channel, e.g.
|
|
155
|
+
* +[:front_left, :front_right]+
|
|
156
|
+
*/
|
|
101
157
|
static VALUE Music_channel_map(VALUE self) {
|
|
102
158
|
size_t count = 0;
|
|
103
159
|
const sfSoundChannel* map = sfMusic_getChannelMap(Get_Music_Struct(self), &count);
|
|
@@ -119,12 +175,26 @@ static VALUE Music_channel_map(VALUE self) {
|
|
|
119
175
|
|
|
120
176
|
/* Loop points are an offset plus a length, matching sfTimeSpan. Returned as a
|
|
121
177
|
two-element [offset, length] pair of SFML::Time. */
|
|
178
|
+
/* call-seq: loop_points -> [Time, Time]
|
|
179
|
+
*
|
|
180
|
+
* Returns the loop points as an +[offset, length]+ pair.
|
|
181
|
+
*
|
|
182
|
+
* @return [Array<Time>] a two-element +[offset, length]+ pair
|
|
183
|
+
*/
|
|
122
184
|
static VALUE Music_loop_points(VALUE self) {
|
|
123
185
|
sfTimeSpan span = sfMusic_getLoopPoints(Get_Music_Struct(self));
|
|
124
186
|
|
|
125
187
|
return rb_ary_new_from_args(2, time_to_rb(span.offset), time_to_rb(span.length));
|
|
126
188
|
}
|
|
127
189
|
|
|
190
|
+
/* call-seq:
|
|
191
|
+
* loop_points=(value) -> [Time, Time]
|
|
192
|
+
*
|
|
193
|
+
* Sets the loop points as a two-element +[offset, length]+ pair.
|
|
194
|
+
*
|
|
195
|
+
* @return [Array<Time>] +value+
|
|
196
|
+
* @raise [ArgumentError] if +value+ is not a two-element Array
|
|
197
|
+
*/
|
|
128
198
|
static VALUE Music_set_loop_points(VALUE self, VALUE rb_span) {
|
|
129
199
|
sfTimeSpan span;
|
|
130
200
|
|
|
@@ -146,8 +216,145 @@ static VALUE Music_set_loop_points(VALUE self, VALUE rb_span) {
|
|
|
146
216
|
#undef SS_FN
|
|
147
217
|
#undef SS_METHOD
|
|
148
218
|
|
|
149
|
-
|
|
150
|
-
|
|
219
|
+
static VALUE Music_alloc(VALUE klass) {
|
|
220
|
+
(void)klass;
|
|
221
|
+
rb_raise(rb_eNotImpError, "use Music.from_file, Music.from_memory or Music.from_stream");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Document-class: SFML::Music
|
|
225
|
+
* Music streamed from a file, memory buffer or InputStream rather than held
|
|
226
|
+
* fully decoded in memory, so it's suited to long tracks that would be
|
|
227
|
+
* wasteful to load whole as a SoundBuffer.
|
|
228
|
+
*
|
|
229
|
+
* @!method play
|
|
230
|
+
* Starts playback, or resumes it when paused.
|
|
231
|
+
* @return [self]
|
|
232
|
+
* @!method pause
|
|
233
|
+
* Pauses playback, keeping the current playing offset.
|
|
234
|
+
* @return [self]
|
|
235
|
+
* @!method stop
|
|
236
|
+
* Stops playback and rewinds to the beginning. May briefly block the
|
|
237
|
+
* calling thread if an audio-thread callback for this source is in
|
|
238
|
+
* flight.
|
|
239
|
+
* @return [self]
|
|
240
|
+
* @!method status
|
|
241
|
+
* Returns the current playback status.
|
|
242
|
+
* @return [Symbol] one of +:stopped+, +:paused+, +:playing+
|
|
243
|
+
* @!method looping?
|
|
244
|
+
* Returns +true+ if playback loops back to the start on completion.
|
|
245
|
+
* @return [Boolean]
|
|
246
|
+
* @!method looping=(value)
|
|
247
|
+
* Enables or disables looping.
|
|
248
|
+
* @return [Boolean]
|
|
249
|
+
* @!method pitch
|
|
250
|
+
* Returns the pitch scaling factor.
|
|
251
|
+
* @return [Float]
|
|
252
|
+
* @!method pitch=(value)
|
|
253
|
+
* Sets the pitch scaling factor.
|
|
254
|
+
* @return [Float]
|
|
255
|
+
* @!method pan
|
|
256
|
+
* Returns the source's stereo pan.
|
|
257
|
+
* @return [Float] stereo pan, -1 (left) to 1 (right)
|
|
258
|
+
* @!method pan=(value)
|
|
259
|
+
* Sets the source's stereo pan.
|
|
260
|
+
* @return [Float]
|
|
261
|
+
* @!method volume
|
|
262
|
+
* Returns the source's volume.
|
|
263
|
+
* @return [Float] 0 to 100
|
|
264
|
+
* @!method volume=(value)
|
|
265
|
+
* Sets the source's volume.
|
|
266
|
+
* @return [Float]
|
|
267
|
+
* @!method spatialization_enabled?
|
|
268
|
+
* Returns +true+ if 3D spatialization is enabled.
|
|
269
|
+
* @return [Boolean]
|
|
270
|
+
* @!method spatialization_enabled=(value)
|
|
271
|
+
* Enables or disables 3D spatialization.
|
|
272
|
+
* @return [Boolean]
|
|
273
|
+
* @!method position
|
|
274
|
+
* Returns the source's position in 3D space.
|
|
275
|
+
* @return [Vector3]
|
|
276
|
+
* @!method position=(value)
|
|
277
|
+
* Sets the source's position in 3D space.
|
|
278
|
+
* @return [Vector3]
|
|
279
|
+
* @!method direction
|
|
280
|
+
* Returns the direction the source is facing.
|
|
281
|
+
* @return [Vector3]
|
|
282
|
+
* @!method direction=(value)
|
|
283
|
+
* Sets the direction the source is facing.
|
|
284
|
+
* @return [Vector3]
|
|
285
|
+
* @!method velocity
|
|
286
|
+
* Returns the source's velocity, used for Doppler calculations.
|
|
287
|
+
* @return [Vector3]
|
|
288
|
+
* @!method velocity=(value)
|
|
289
|
+
* Sets the source's velocity for Doppler calculations.
|
|
290
|
+
* @return [Vector3]
|
|
291
|
+
* @!method cone
|
|
292
|
+
* Returns the source's directional attenuation cone.
|
|
293
|
+
* @return [SoundSourceCone]
|
|
294
|
+
* @!method cone=(value)
|
|
295
|
+
* Sets the source's directional attenuation cone.
|
|
296
|
+
* @return [SoundSourceCone]
|
|
297
|
+
* @!method doppler_factor
|
|
298
|
+
* Returns the factor by which the Doppler effect is scaled.
|
|
299
|
+
* @return [Float]
|
|
300
|
+
* @!method doppler_factor=(value)
|
|
301
|
+
* Sets the factor by which the Doppler effect is scaled.
|
|
302
|
+
* @return [Float]
|
|
303
|
+
* @!method directional_attenuation_factor
|
|
304
|
+
* Returns the factor controlling directional attenuation.
|
|
305
|
+
* @return [Float]
|
|
306
|
+
* @!method directional_attenuation_factor=(value)
|
|
307
|
+
* Sets the factor controlling directional attenuation.
|
|
308
|
+
* @return [Float]
|
|
309
|
+
* @!method relative_to_listener?
|
|
310
|
+
* Returns +true+ if the source is positioned relative to the listener.
|
|
311
|
+
* @return [Boolean]
|
|
312
|
+
* @!method relative_to_listener=(value)
|
|
313
|
+
* Makes the source relative to, or independent of, the listener.
|
|
314
|
+
* @return [Boolean]
|
|
315
|
+
* @!method min_distance
|
|
316
|
+
* Returns the minimum distance of the distance-attenuation model.
|
|
317
|
+
* @return [Float]
|
|
318
|
+
* @!method min_distance=(value)
|
|
319
|
+
* Sets the minimum distance of the distance-attenuation model.
|
|
320
|
+
* @return [Float]
|
|
321
|
+
* @!method max_distance
|
|
322
|
+
* Returns the maximum distance of the distance-attenuation model.
|
|
323
|
+
* @return [Float]
|
|
324
|
+
* @!method max_distance=(value)
|
|
325
|
+
* Sets the maximum distance of the distance-attenuation model.
|
|
326
|
+
* @return [Float]
|
|
327
|
+
* @!method min_gain
|
|
328
|
+
* Returns the minimum gain of the distance-attenuation model.
|
|
329
|
+
* @return [Float]
|
|
330
|
+
* @!method min_gain=(value)
|
|
331
|
+
* Sets the minimum gain of the distance-attenuation model.
|
|
332
|
+
* @return [Float]
|
|
333
|
+
* @!method max_gain
|
|
334
|
+
* Returns the maximum gain of the distance-attenuation model.
|
|
335
|
+
* @return [Float]
|
|
336
|
+
* @!method max_gain=(value)
|
|
337
|
+
* Sets the maximum gain of the distance-attenuation model.
|
|
338
|
+
* @return [Float]
|
|
339
|
+
* @!method attenuation
|
|
340
|
+
* Returns the distance-attenuation factor.
|
|
341
|
+
* @return [Float]
|
|
342
|
+
* @!method attenuation=(value)
|
|
343
|
+
* Sets the distance-attenuation factor.
|
|
344
|
+
* @return [Float]
|
|
345
|
+
* @!method playing_offset
|
|
346
|
+
* Returns the current playing offset.
|
|
347
|
+
* @return [Time]
|
|
348
|
+
* @!method playing_offset=(value)
|
|
349
|
+
* Seeks to the given playing offset.
|
|
350
|
+
* @return [Time]
|
|
351
|
+
* @!method effect_processor=(proc)
|
|
352
|
+
* Installs a Proc that post-processes this source's audio in real time.
|
|
353
|
+
* @return [Proc] +proc+
|
|
354
|
+
*/
|
|
355
|
+
void Init_Music(VALUE rb_mSFML) {
|
|
356
|
+
rb_cMusic = rb_define_class_under(rb_mSFML, "Music", rb_cObject);
|
|
357
|
+
rb_define_alloc_func(rb_cMusic, Music_alloc);
|
|
151
358
|
|
|
152
359
|
rb_define_singleton_method(rb_cMusic, "from_file", Music_from_file, 1);
|
|
153
360
|
rb_define_singleton_method(rb_cMusic, "from_memory", Music_from_memory, 1);
|