Class: Osb::Sample

Inherits:
Object
  • Object
show all
Defined in:
lib/osb/sample.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time:, layer:, file_path:, volume: 100) ⇒ Sample

Returns a new instance of Sample.

Parameters:

  • time (Integer)

    the timestamp that the sound should start playing.

  • layer (String)

    the layer you want the sound to be on.

  • file_path (String)

    filename of the audio.

  • volume (Integer) (defaults to: 100)

    indicate the relative loudness of the sound.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/osb/sample.rb', line 10

def initialize(time:, layer:, file_path:, volume: 100)
  Internal.assert_type!(layer, String, "layer")
  Internal.assert_value!(layer, Layer::ALL, "layer")
  Internal.assert_type!(file_path, String, "file_path")

  layer_ =
    case layer
    when Osb::Layer::Background
      0
    when Osb::Layer::Foreground
      1
    when Osb::Layer::Fail
      2
    when Osb::Layer::Pass
      3
    else
      raise InvalidValueError,
            "An audio sample can only exists in one of these layers: " +
              "Background, Foreground, Fail or Pass."
    end

  @command = "Sample,#{time},#{layer_},\"#{file_path}}\",#{volume}"
end

Instance Attribute Details

#commandObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



4
5
6
# File 'lib/osb/sample.rb', line 4

def command
  @command
end