チュートリアル
使ってみる「音量調節・テンポ調節・パン調節」 (Ogg)
これらの設定は、再生中に動的に変えることができます。
setOggVolume()で音量、
setOggTempo()でテンポ、
setOggPan()でパン(左右のスピーカーの音量バランス)を、調節できます。
上記のメソッドを使った後に、updatePlayingInfomation()を使うと、設定がMusicPlayerに反映されます。
[Main.tonyu]
extends SpriteChar;
$mplayer = new Ymplayer();
// 開発環境版 でOggを鳴らすための処理 ////
$mplayer.updatePlayingInfomation(); // 更新
$mplayer.play($se_test, 0); // Tonyu開発環境版では、プロジェクトを開いてから一度midiを再生しないとoggを再生できない
wait(20);
$mplayer.stop();
wait(20);
//////////////////////////////////////////
$mplayer.play("test.ogg", 1); // 再生
oggVolume = 127;
oggTempo = 1;
oggPan = 0;
v = 1;
while (1) {
if (getkey(65) > 0) oggVolume --; // A:音量−
if (getkey(83) > 0) oggVolume ++; // S:音量+
if (getkey(68) > 0) oggTempo -= 0.125; // D:テンポ−
if (getkey(70) > 0) oggTempo += 0.125; // F:テンポ+
if (getkey(71) > 0) oggPan -= 1 / 64; // G:パン−
if (getkey(72) > 0) oggPan += 1 / 64; // H:パン+
if (v % 6 == 0) { // 1秒間に10回更新
$mplayer.setOggVolume(oggVolume); // 音量設定
$mplayer.setOggTempo(oggTempo); // テンポ設定
$mplayer.setOggPan(oggPan); // パン設定
$mplayer.updatePlayingInfomation(); // 更新
}
drawText(100, 0, "音量 :" + oggVolume, $clWhite);
drawText(100, 20, "テンポ:" + oggTempo , $clWhite);
drawText(100, 40, "パン :" + oggPan , $clWhite);
v++;
update();
}
メソッドの詳細
戻る