1
1
# Copyright (C) 2015 Oleh Prypin <[email protected] >
2
- #
2
+ #
3
3
# This file is part of CrSFML.
4
- #
4
+ #
5
5
# This software is provided 'as-is', without any express or implied
6
6
# warranty. In no event will the authors be held liable for any damages
7
7
# arising from the use of this software.
8
- #
8
+ #
9
9
# Permission is granted to anyone to use this software for any purpose,
10
10
# including commercial applications, and to alter it and redistribute it
11
11
# freely, subject to the following restrictions:
12
- #
12
+ #
13
13
# 1. The origin of this software must not be misrepresented; you must not
14
14
# claim that you wrote the original software. If you use this software
15
15
# in a product, an acknowledgement in the product documentation would be
@@ -22,31 +22,31 @@ require "./audio_lib"
22
22
23
23
module SF
24
24
extend self
25
-
25
+
26
26
class Sound
27
27
def initialize (buffer: SoundBuffer )
28
28
initialize()
29
29
self .buffer = buffer
30
30
end
31
31
end
32
-
32
+
33
33
class SoundBuffer
34
34
def to_slice
35
35
samples.to_slice(sample_count.to_i)
36
36
end
37
37
end
38
-
38
+
39
39
class SoundRecorder
40
40
def self.available_devices
41
41
ptr = CSFML .sound_recorder_get_available_devices(out count)
42
42
ptr.to_slice(count.to_i).map { |p | p ? String .new(p) : " " }
43
43
end
44
-
44
+
45
45
def start ()
46
46
start(44100 )
47
47
end
48
48
end
49
-
49
+
50
50
class SoundBufferRecorder
51
51
def self.available ?
52
52
SoundRecorder .available?
@@ -57,19 +57,19 @@ module SF
57
57
def self.available_devices
58
58
SoundRecorder .available_devices
59
59
end
60
-
60
+
61
61
def start ()
62
62
start(44100 )
63
63
end
64
64
end
65
-
65
+
66
66
class SoundStream
67
67
abstract def on_get_data (): Slice (Int16 )
68
68
abstract def on_seek (position: Time ): Void
69
-
69
+
70
70
# :nodoc:
71
71
alias FuncBox = Box ({(CSFML ::SoundStreamChunk * - > CSFML ::Bool ), (Time - > Nil )})
72
-
72
+
73
73
def initialize (channel_count: Int , sample_rate: Int )
74
74
@owned = true
75
75
@funcs = FuncBox .box({
@@ -94,10 +94,10 @@ module SF
94
94
abstract def on_start (): Bool
95
95
abstract def on_process_samples (samples: Slice (Int16 )): Bool
96
96
abstract def on_stop (): Void
97
-
97
+
98
98
# :nodoc:
99
99
alias FuncBox = Box ({(- > CSFML ::Bool ), ((Int16 * , LibC ::SizeT ) - > CSFML ::Bool ), (- > Nil )})
100
-
100
+
101
101
def initialize ()
102
102
@owned = true
103
103
@funcs = FuncBox .box({
0 commit comments