Class: Bloops

Inherits:
Object
  • Object
show all
Defined in:
ext/ruby/rubyext.c

Defined Under Namespace

Classes: Sound, Track

Instance Method Summary collapse

Instance Method Details

#clearObject



33
34
35
36
37
38
39
40
# File 'ext/ruby/rubyext.c', line 33

VALUE
rb_bloops_clear(VALUE self)
{
  bloops *B;
  Data_Get_Struct(self, bloops, B);
  bloops_clear(B);
  return self;
}

#load(fname) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'ext/ruby/rubyext.c', line 85

VALUE
rb_bloops_load(VALUE self, VALUE fname)
{
  bloops *B;
  bloopsaphone *P;
  Data_Get_Struct(self, bloops, B);

  StringValue(fname);
  P = bloops_sound_file(B, RSTRING_PTR(fname));
  if (P == NULL) return Qnil;
  return Data_Wrap_Struct(cSound, NULL, rb_bloops_sound_free, P);
}

#playObject



42
43
44
45
46
47
48
49
# File 'ext/ruby/rubyext.c', line 42

VALUE
rb_bloops_play(VALUE self)
{
  bloops *B;
  Data_Get_Struct(self, bloops, B);
  bloops_play(B);
  return self;
}

#sound(type) ⇒ Object



98
99
100
101
102
103
104
# File 'ext/ruby/rubyext.c', line 98

VALUE
rb_bloops_sound(VALUE self, VALUE type)
{
  bloopsaphone *P = bloops_square();
  P->type = (unsigned char)NUM2INT(type);
  return Data_Wrap_Struct(cSound, NULL, rb_bloops_sound_free, P);
}

#stopped?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
# File 'ext/ruby/rubyext.c', line 51

VALUE
rb_bloops_is_stopped(VALUE self)
{
  bloops *B;
  Data_Get_Struct(self, bloops, B);
  return bloops_is_done(B) ? Qtrue : Qfalse;
}

#tempoObject



59
60
61
62
63
64
65
# File 'ext/ruby/rubyext.c', line 59

VALUE
rb_bloops_get_tempo(VALUE self)
{
  bloops *B;
  Data_Get_Struct(self, bloops, B);
  return INT2NUM(B->tempo);
}

#tempo=(tempo) ⇒ Object



67
68
69
70
71
72
73
74
# File 'ext/ruby/rubyext.c', line 67

VALUE
rb_bloops_set_tempo(VALUE self, VALUE tempo)
{
  bloops *B;
  Data_Get_Struct(self, bloops, B);
  bloops_tempo(B, NUM2INT(tempo));
  return tempo;
}

#tune(sound, notes) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'ext/ruby/rubyext.c', line 170

VALUE
rb_bloops_tune(VALUE self, VALUE sound, VALUE notes)
{
  int i;
  bloops *B;
  bloopsaphone *phone;
  bloopsatrack *track;
  Data_Get_Struct(self, bloops, B);
  Data_Get_Struct(sound, bloopsaphone, phone);

  StringValue(notes);
  track = bloops_track(B, phone, RSTRING_PTR(notes), RSTRING_LEN(notes));

  for (i = 0; i < BLOOPS_MAX_TRACKS; i++)
    if (B->tracks[i] == NULL) {
      bloops_track_at(B, track, i);
      break;
    }
  return Data_Wrap_Struct(cTrack, NULL, rb_bloops_track_free, track);
}