Skip to content

Commit 243398f

Browse files
authored
Merge pull request #544 from StopMotionEGames/development
Fix the note preview when adding a note or changing the key/volume/panning
2 parents 1383fe4 + 30c92da commit 243398f

7 files changed

Lines changed: 54 additions & 38 deletions

File tree

scripts/add_block_manual/add_block_manual.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function add_block_manual(argument0, argument1, argument2, argument3, argument4,
6868
if (xx >= songs[song].enda) songs[song].enda = xx
6969
if (yy >= songs[song].endb) songs[song].endb = yy
7070

71-
if (ins.loaded) play_sound(ins, key, vel, pan, pit)
71+
if (ins.loaded) play_sound(ins, key, (songs[song].layervol[yy] / 100 ) * vel, (songs[song].layerstereo[yy] + pan) / 2, pit)
7272
history_set(h_addblock, xx, yy, ins, key, vel, pan, pit)
7373

7474
var insname = songs[song].instrument_list[| ds_list_find_index(songs[song].instrument_list, ins)].name

scripts/change_block_manual/change_block_manual.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function change_block_manual(argument0, argument1, argument2, argument3, argumen
2525
songs[song].song_pit[xx, yy] = pit
2626
}
2727

28-
if (ins.loaded) play_sound(ins, key, vel, pan, pit)
28+
if (ins.loaded) play_sound(ins, key, (songs[song].layervol[yy] / 100 ) * vel, (songs[song].layerstereo[yy] + pan) / 2, pit)
2929

3030
var insname = songs[song].instrument_list[| ds_list_find_index(songs[song].instrument_list, ins)].name
3131
if (insname = "Tempo Changer") {

scripts/control_create/control_create.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ function control_create() {
395395

396396
mousewheel = 0
397397
changepitch = 1
398+
layerhov_vppreview = 0
398399

399400
keynames = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"];
400401
keynames_flat = 0

scripts/control_draw/control_draw.gml

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function control_draw() {
22
// control_draw()
3-
var a, b, c, d, e, f, g, p, l, s, exist, str, str2, m, xx, x1, y1, x2, y2, iconcolor, showmenu, totalcols, totalrows, compx, prev, colr, note_offset;
3+
var a, b, c, d, e, f, g, p, l, s, exist, str, str2, m, xx, x1, y1, x2, y2, iconcolor, showmenu, totalcols, totalrows, compx, prev, colr, note_offset,
4+
preview_pan = 100, preview_vol = 100;
45

56
var checkplaying = playing - playing_prev
67
playing_prev = playing
@@ -224,40 +225,47 @@ function control_draw() {
224225
}
225226
}
226227
}
227-
if (mousewheel = 1 && window = 0 && (exist = 0 || changepitch = 0) && !isplayer && !volume_scroll) {
228-
var insindex = ds_list_find_index(current_song.instrument_list, current_song.instrument)
229-
if (mouse_wheel_down_dynamic() && insindex > 0) {
230-
insindex--
231-
current_song.instrument = current_song.instrument_list[| insindex]
232-
selected_vel = 100
233-
selected_pan = 100
234-
selected_pit = 0
235-
play_sound(current_song.instrument, selected_key, 100 ,100, 0)
236-
}
237-
if (mouse_wheel_up_dynamic() && insindex < ds_list_size(current_song.instrument_list) - 1) {
238-
insindex++
239-
current_song.instrument = current_song.instrument_list[| insindex]
240-
selected_vel = 100
241-
selected_pan = 100
242-
selected_pit = 0
243-
play_sound(current_song.instrument, selected_key, 100 ,100, 0)
244-
}
245-
}
246-
if (mousewheel = 2 && window = 0 && (exist = 0 || changepitch = 0) && !isplayer && !volume_scroll) {
247-
if (mouse_wheel_down_dynamic() && selected_key > 0) {
248-
selected_key -= 1
249-
selected_vel = 100
250-
selected_pan = 100
251-
selected_pit = 0
252-
play_sound(current_song.instrument, selected_key, 100 ,100, 0)
253-
}
254-
if (mouse_wheel_up_dynamic() && selected_key < 87) {
255-
selected_key += 1
256-
selected_vel = 100
257-
selected_pan = 100
258-
selected_pit = 0
259-
play_sound(current_song.instrument, selected_key, 100 ,100, 0)
260-
}
228+
229+
// scroll to change the instument or key if enabled. Also check if user scrolled before continue
230+
if (window = 0 && (mouse_wheel_down_dynamic() || mouse_wheel_up_dynamic()) && (exist = 0 || changepitch = 0) && !isplayer && !volume_scroll) {
231+
232+
selected_vel = 100
233+
selected_pan = 100
234+
selected_pit = 0
235+
236+
var insindex = ds_list_find_index(current_song.instrument_list, current_song.instrument)
237+
238+
if (mouse_wheel_down_dynamic()) {
239+
if (mousewheel = 1 && insindex > 0) {
240+
insindex--
241+
current_song.instrument = current_song.instrument_list[| insindex]
242+
}
243+
244+
if (mousewheel = 2 && selected_key > 0) {
245+
selected_key -= 1
246+
}
247+
}
248+
249+
if (mouse_wheel_up_dynamic()) {
250+
if (mousewheel = 1 && insindex < ds_list_size(current_song.instrument_list) - 1) {
251+
insindex++
252+
current_song.instrument = current_song.instrument_list[| insindex]
253+
}
254+
255+
if (mousewheel = 2 && selected_key < 87) {
256+
selected_key += 1
257+
}
258+
}
259+
260+
preview_vol =
261+
(selby >= 0 && selby <= current_song.endb && layerhov_vppreview)
262+
? (songs[song].layervol[selby] / 100 ) * selected_vel : 100
263+
264+
preview_pan =
265+
(selby >= 0 && selby <= current_song.endb && layerhov_vppreview)
266+
? (songs[song].layerstereo[selby] + selected_pan) / 2 : 100
267+
268+
play_sound(current_song.instrument, selected_key, preview_vol, preview_pan, 0)
261269
}
262270

263271
// Draw note blocks
@@ -475,12 +483,15 @@ function control_draw() {
475483
selected_vel = current_song.song_vel[selbx, selby]
476484
selected_pan = current_song.song_pan[selbx, selby]
477485
selected_pit = current_song.song_pit[selbx, selby]
486+
487+
preview_vol = (songs[song].layervol[selby] / 100 ) * selected_vel
488+
preview_pan = (songs[song].layerstereo[selby] + selected_pan) / 2
478489
} else {
479490
selected_vel = 100
480491
selected_pan = 100
481492
selected_pit = 0
482493
}
483-
play_sound(current_song.instrument, selected_key, selected_vel, selected_pan, selected_pit)
494+
play_sound(current_song.instrument, selected_key, preview_vol, preview_pan, selected_pit)
484495
}
485496

486497
}

scripts/draw_window_preferences/draw_window_preferences.gml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ function draw_window_preferences() {
532532
if (draw_radiobox(x1 + 40, y1 + 110 + (theme = 3) * 22, mousewheel = 1, "Use mouse wheel to change instrument", "Use the mouse wheel to toggle between\nthe available instruments.")) mousewheel = 1
533533
if (draw_radiobox(x1 + 40, y1 + 130 + (theme = 3) * 22, mousewheel = 2, "Use mouse wheel to change key", "Use the mouse wheel to toggle\nbetween the keys on the piano.")) mousewheel = 2
534534
if (draw_checkbox(x1 + 40, y1 + 158 + (theme = 3) * 22, changepitch, "Change note properties when scrolling over notes", "Whether scrolling when hovering over a note should change its key,\nvelocity, panning or pitch, according to the currently selected edit mode.")) changepitch=!changepitch
535+
if (draw_checkbox(x1 + 40, y1 + 178 + (theme = 3) * 22, layerhov_vppreview , "Apply hovered layer's volume and panning to note preview sounds", "Whether the preview sound's volume and panning should be\nrelative to the layer the mouse is hovering over.")) layerhov_vppreview =!layerhov_vppreview
535536
//draw_text_dynamic(x1 + 40, y1 + 178, "Tip: Hold Shift while scrolling over a note to change a whole octave,\nor fine-tune its velocity, panning or pitch.")
536537
if (theme = 3) draw_theme_font(font_info_med)
537538
draw_areaheader(x1 + 22, y1 + 220 + (theme = 3) * 22, 456, 105, "Piano")
@@ -549,6 +550,7 @@ function draw_window_preferences() {
549550
if (draw_radiobox(x1 + 40, y1 + 110 + (theme = 3) * 22, mousewheel = 1, "使用鼠标滚轮改变音色", "使用鼠标滚轮切换可用音色。")) mousewheel = 1
550551
if (draw_radiobox(x1 + 40, y1 + 130 + (theme = 3) * 22, mousewheel = 2, "使用鼠标滚轮改变音调", "使用鼠标滚轮改变目前使用的音调。")) mousewheel = 2
551552
if (draw_checkbox(x1 + 40, y1 + 158 + (theme = 3) * 22, changepitch, "当在音符上使用鼠标滚轮改变音符属性", "在音符上使用鼠标滚轮时是否根据目前模式改变其音调、音量、声道或音高。")) changepitch=!changepitch
553+
if (draw_checkbox(x1 + 40, y1 + 178 + (theme = 3) * 22, layerhov_vppreview , "将悬停图层的音量和声像调整应用于音符预览声音", "预览声音的音量和声像定位是否应与鼠标悬停的图层相关。")) layerhov_vppreview =!layerhov_vppreview
552554
//draw_text_dynamic(x1 + 40, y1 + 178, "Tip: Hold Shift while scrolling over a note to change a whole octave,\nor fine-tune its velocity, panning or pitch.")
553555
if (theme = 3) draw_theme_font(font_info_med)
554556
draw_areaheader(x1 + 22, y1 + 220 + (theme = 3) * 22, 456, 105, "琴键")

scripts/load_settings/load_settings.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function load_settings() {
4747
show_outofrange = ini_read_real( "preferences", "show_outofrange", show_outofrange)
4848
mousewheel = ini_read_real( "preferences", "mousewheel", mousewheel)
4949
changepitch = ini_read_real( "preferences", "change_pitch", changepitch)
50+
layerhov_vppreview = ini_read_real( "preferences", "layerhov_vppreview", layerhov_vppreview)
5051
select_lastpressed = ini_read_real( "preferences", "select_lastpressed", select_lastpressed)
5152
marker_follow = ini_read_real( "preferences", "marker_follow", marker_follow)
5253
marker_pagebypage = ini_read_real( "preferences", "marker_pagebypage", marker_pagebypage)

scripts/save_settings/save_settings.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function save_settings() {
4545
ini_write_real_clean("preferences", "show_outofrange", show_outofrange)
4646
ini_write_real_clean("preferences", "mousewheel", mousewheel)
4747
ini_write_real_clean("preferences", "change_pitch", changepitch)
48+
ini_write_real_clean("preferences", "layerhov_vppreview", layerhov_vppreview)
4849
ini_write_real_clean("preferences", "select_lastpressed", select_lastpressed)
4950
ini_write_real_clean("preferences", "marker_follow", marker_follow)
5051
ini_write_real_clean("preferences", "marker_pagebypage", marker_pagebypage)

0 commit comments

Comments
 (0)