Class: Music

Inherits:
Object
  • Object
show all
Defined in:
mrb_doc/models/music.rb

Overview

The Music class holds longer format sound files, very useful for background music.

Defined Under Namespace

Classes: NotFound, Type

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_type, looping, frame_count) ⇒ Music

Creates a new instance of Music

Parameters:

  • context_type (Integer)

    A value between 0 and 6

  • looping (Boolean)
  • frame_count (Integer)


18
19
20
21
22
# File 'mrb_doc/models/music.rb', line 18

def initialize(context_type, looping, frame_count)
  # mrb_Music_initialize
  # src/mruby_integration/models/music.cpp
  Music.new
end

Instance Attribute Details

#context_typeInteger

Returns:

  • (Integer)


5
6
7
# File 'mrb_doc/models/music.rb', line 5

def context_type
  @context_type
end

#frame_countInteger

Returns:

  • (Integer)


5
6
7
# File 'mrb_doc/models/music.rb', line 5

def frame_count
  @frame_count
end

#loopingBoolean

Returns:

  • (Boolean)


11
12
13
# File 'mrb_doc/models/music.rb', line 11

def looping
  @looping
end

#pitchFloat

Returns:

  • (Float)


8
9
10
# File 'mrb_doc/models/music.rb', line 8

def pitch
  @pitch
end

#volumeFloat

Returns:

  • (Float)


8
9
10
# File 'mrb_doc/models/music.rb', line 8

def volume
  @volume
end

Class Method Details

.load(path) ⇒ Music

Loads a music file from the specified path

Parameters:

  • path (String)

Returns:

Raises:



57
58
59
60
# File 'mrb_doc/models/music.rb', line 57

def self.load(path)
  # src/mruby_integration/models/music.cpp
  Music.new
end

Instance Method Details

#lengthFloat

How long does this music go for?

Returns:

  • (Float)


114
115
116
117
# File 'mrb_doc/models/music.rb', line 114

def length
  # src/mruby_integration/models/music.cpp
  3.14
end

#pausenil

Pauses the music, you will need to call Music#resume to start it again

Returns:

  • (nil)


100
101
102
103
# File 'mrb_doc/models/music.rb', line 100

def pause
  # src/mruby_integration/models/music.cpp
  nil
end

#playnil

Starts playing the music

Returns:

  • (nil)


71
72
73
74
# File 'mrb_doc/models/music.rb', line 71

def play
  # src/mruby_integration/models/music.cpp
  nil
end

#playedFloat

How long has the music been played for this loop?

Returns:

  • (Float)


121
122
123
124
# File 'mrb_doc/models/music.rb', line 121

def played
  # src/mruby_integration/models/music.cpp
  2.17
end

#playing?Boolean

Is the music currently playing?

Returns:

  • (Boolean)


86
87
88
89
# File 'mrb_doc/models/music.rb', line 86

def playing?
  # src/mruby_integration/models/music.cpp
  true
end

#resumenil

Resumes the music playing

Returns:

  • (nil)


107
108
109
110
# File 'mrb_doc/models/music.rb', line 107

def resume
  # src/mruby_integration/models/music.cpp
  nil
end

#stopnil

Stops the music, you will need to call Music#play to start it again

Returns:

  • (nil)


93
94
95
96
# File 'mrb_doc/models/music.rb', line 93

def stop
  # src/mruby_integration/models/music.cpp
  nil
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (Hash)


44
45
46
47
48
49
50
51
# File 'mrb_doc/models/music.rb', line 44

def to_h
  # src/mruby_integration/models/music.cpp
  {
    context_type: context_type,
    looping: looping,
    frame_count: frame_count,
  }
end

#unloadnil

Unloads the music from memory

Returns:

  • (nil)


64
65
66
67
# File 'mrb_doc/models/music.rb', line 64

def unload
  # src/mruby_integration/models/music.cpp
  nil
end

#updatenil

This method should be called every update to keep the music playing smoothly

Returns:

  • (nil)


79
80
81
82
# File 'mrb_doc/models/music.rb', line 79

def update
  # src/mruby_integration/models/music.cpp
  nil
end