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



94
95
96
97
98
99
100
101
102
103
104
105
# File 'ext/ruby/rubyext.c', line 94

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;
}

#record(path) ⇒ Object



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

VALUE
rb_bloops_record(VALUE self, VALUE path)
{
  bloops *B;
  Data_Get_Struct(self, bloops, B);
  int result = bloops_record(B, StringValuePtr(path));
  return self;
}

#sound(type) ⇒ Object



107
108
109
110
111
112
113
# File 'ext/ruby/rubyext.c', line 107

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)


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

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

#tempoObject



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

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

#tempo=(tempo) ⇒ Object



76
77
78
79
80
81
82
83
# File 'ext/ruby/rubyext.c', line 76

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



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'ext/ruby/rubyext.c', line 179

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);
}