static IntPtr me_play(IntPtr Self, IntPtr Args) { Ruby.Array.Expect(Args, 1, 2, 3); if (Ruby.Array.Is(Args, 0, "Sound")) { odl.Sound sound = Sound.SoundDictionary[Ruby.Array.Get(Args, 0)]; odl.Audio.MEPlay(sound); } else { Ruby.Array.Expect(Args, 0, "String"); string Filename = Ruby.String.FromPtr(Ruby.Array.Get(Args, 0)); int Volume = 100; int Pitch = 0; long len = Ruby.Array.Length(Args); if (len >= 2) { Ruby.Array.Expect(Args, 1, "Integer"); Volume = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 1)); } if (len == 3) { Ruby.Array.Expect(Args, 2, "Integer"); Pitch = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 2)); } odl.Audio.MEPlay(Filename, Volume, Pitch); } return(Ruby.True); }
static IntPtr initialize(IntPtr Self, IntPtr Args) { Ruby.Array.Expect(Args, 1, 2, 3); long len = Ruby.Array.Length(Args); Ruby.Array.Expect(Args, 0, "String"); Ruby.SetIVar(Self, "@filename", Ruby.Array.Get(Args, 0)); string Filename = Ruby.String.FromPtr(Ruby.Array.Get(Args, 0)); int Volume = 100; int Pitch = 0; if (len >= 2) { Ruby.Array.Expect(Args, 1, "Integer"); Ruby.SetIVar(Self, "@volume", Ruby.Array.Get(Args, 1)); Volume = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 1)); } else { Ruby.SetIVar(Self, "@volume", Ruby.Integer.ToPtr(100)); } if (len >= 3) { Ruby.Array.Expect(Args, 2, "Integer"); Ruby.SetIVar(Self, "@pitch", Ruby.Array.Get(Args, 2)); Pitch = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 2)); } else { Ruby.SetIVar(Self, "@pitch", Ruby.Integer.ToPtr(0)); } if (SoundDictionary.ContainsKey(Self)) { SoundDictionary[Self].Stop(); SoundDictionary.Remove(Self); } odl.Sound sound = new odl.Sound(Filename, Volume, Pitch); Ruby.SetIVar(Self, "@length", Ruby.Integer.ToPtr(sound.Length)); SoundDictionary.Add(Self, sound); return(Self); }