Skip to content

Commit

Permalink
Support changing music speed
Browse files Browse the repository at this point in the history
(but also changing pitch)
  • Loading branch information
NagaseIori committed Jun 1, 2022
1 parent 555e407 commit d6be00a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions objects/objmain/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
animTargetOffset = chartOffset;

musicProgress = 0.0;
musicSpeed = 1.0;

// FMODGMS Related

Expand Down
3 changes: 2 additions & 1 deletion objects/objmain/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ var _nw = global.resolutionW, _nh = global.resolutionH;

var _debug_str = "";
_debug_str += "FPS: " + string(fps) + "\nRFPS: "+string(fps_real)+"\n";
_debug_str += "DSPD: " + string(playbackSpeed);
_debug_str += "DSPD: " + string(playbackSpeed)+"\n";
_debug_str += "MSPD: " + string(musicSpeed)+"\n";
draw_set_font(fDynamix20);
draw_set_halign(fa_center);
draw_set_valign(fa_top);
Expand Down
14 changes: 13 additions & 1 deletion objects/objmain/Step_0.gml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@

_position_update();

// Music Speed Adjust



var _muspdchange = keyboard_check_pressed(ord("W")) - keyboard_check_pressed(ord("S"));
if(_muspdchange != 0) {
musicSpeed += 0.1 * _muspdchange;
musicSpeed = max(musicSpeed, 0.1);
// FMODGMS_Chan_Set_Frequency(channel, sampleRate * musicSpeed);
FMODGMS_Chan_Set_Pitch(channel, musicSpeed);
}

// Keyboard Time Adjust

var _spdchange = keyboard_check_pressed(ord("E")) - keyboard_check_pressed(ord("Q"));
Expand All @@ -24,7 +36,7 @@ _position_update();
// Time Operation

if(nowPlaying && !(_timchange != 0 || _timscr != 0)) {
nowTime += delta_time / 1000;
nowTime += delta_time * musicSpeed / 1000;
}


Expand Down

0 comments on commit d6be00a

Please sign in to comment.