diff --git a/.gitignore b/.gitignore index ba45ca4..c6d1c63 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ export_presets.cfg # Mono-specific ignores .mono/ +midi/FluidR3 GM.sf2 diff --git a/GridMap/GridMap.gd b/GridMap/GridMap.gd index bee35fd..a88ab27 100644 --- a/GridMap/GridMap.gd +++ b/GridMap/GridMap.gd @@ -35,8 +35,7 @@ const SCORES = [ const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"] const T_SPIN_NAMES = ["", "T-SPIN", "MINI T-SPIN"] -const MIDI_MOVE_CHANNELS = [7, 8, 9, 11] -const MIDI_LINE_CLEAR_CHANNELS = [2, 6, 10] +const MIDI_MOVE_CHANNELS = [] #[7, 8, 9, 11, 12] var next_piece = random_piece() var current_piece @@ -89,6 +88,7 @@ func new_piece(): current_piece = next_piece current_piece.translation = START_POSITION current_piece.emit_trail(true) + update_ghost_piece() autoshift_action = "" update_ghost_piece() next_piece = random_piece() @@ -185,7 +185,7 @@ func rotate(direction): func move_midi(): for channel_id in MIDI_MOVE_CHANNELS: $MidiPlayer.channel_status[channel_id].pan = current_piece.translation.x / 10.0 - mute_midi_channel(MIDI_MOVE_CHANNELS, false) + $MidiPlayer.mute_midi_channels(MIDI_MOVE_CHANNELS, false) $MidiPlayer/MoveDelay.start() func update_ghost_piece(): @@ -232,13 +232,18 @@ func update_score(): score += 100 * s goal -= s print(T_SPIN_NAMES[current_piece.t_spin], ' ', LINES_CLEARED_NAMES[lines_to_clear.size()], " Score ", score) - mute_midi_channel(MIDI_LINE_CLEAR_CHANNELS, false) - $MidiPlayer.play_now() + if lines_to_clear.size() == Tetromino.NB_MINOES: - $MidiPlayer/LineLcearDelay.wait_time = 1.71 + for channel in $MidiPlayer.line_clear_notes: + $MidiPlayer.channel_status[channel].vomume = 127 + $MidiPlayer/LineCLearTimer.wait_time = 0.86 else: - $MidiPlayer/LineLcearDelay.wait_time = 0.86 - $MidiPlayer/LineLcearDelay.start() + for channel in $MidiPlayer.line_clear_notes: + $MidiPlayer.channel_status[channel].vomume = 100 + $MidiPlayer/LineCLearTimer.wait_time = 0.43 + $MidiPlayer.mute_midi_channels($MidiPlayer.line_clear_notes, false) + $MidiPlayer.play_line_clear() + $MidiPlayer/LineCLearTimer.start() if goal <= 0: new_level() else: @@ -271,9 +276,9 @@ func resume(): playing = true $DropTimer.start() $LockDelay.start() - $MidiPlayer.play() - mute_midi_channel(MIDI_MOVE_CHANNELS, true) - mute_midi_channel(MIDI_LINE_CLEAR_CHANNELS, true) + $MidiPlayer.resume() + $MidiPlayer.mute_midi_channels(MIDI_MOVE_CHANNELS, true) + $MidiPlayer.mute_midi_channels($MidiPlayer.line_clear_notes, true) print("RESUME") func pause(): @@ -293,13 +298,11 @@ func game_over(): func _notification(what): if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: pause() - -func mute_midi_channel(channels, muted): - for channel_id in channels: - $MidiPlayer.channel_mute[channel_id] = muted + if what == MainLoop.NOTIFICATION_WM_FOCUS_IN: + resume() func _on_MoveDelay_timeout(): - mute_midi_channel(MIDI_MOVE_CHANNELS, true) + $MidiPlayer.mute_midi_channels(MIDI_MOVE_CHANNELS, true) -func _on_LineLcearDelay_timeout(): - mute_midi_channel(MIDI_LINE_CLEAR_CHANNELS, true) +func _on_LineCLearTimer_timeout(): + $MidiPlayer.mute_midi_channels($MidiPlayer.line_clear_notes, true) diff --git a/GridMap/GridMap.tscn b/GridMap/GridMap.tscn index 6f85784..2ba31dc 100644 --- a/GridMap/GridMap.tscn +++ b/GridMap/GridMap.tscn @@ -33,8 +33,8 @@ data = { script = ExtResource( 2 ) _sections_unfolded = [ "Cell", "Transform" ] __meta__ = { -"_editor_clip_": 0, -"_editor_floor_": Vector3( 0, 3, 0 ) +"_editor_clip_": 1, +"_editor_floor_": Vector3( 0, 1, 0 ) } [node name="DropTimer" type="Timer" parent="." index="0"] @@ -89,15 +89,17 @@ mesh = SubResource( 1 ) [node name="GhostPiece" parent="." index="8" instance=ExtResource( 5 )] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0, 0 ) -_sections_unfolded = [ "Transform" ] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 20, 0 ) +_sections_unfolded = [ "Pause", "Transform" ] [node name="MidiPlayer" parent="." index="9" instance=ExtResource( 6 )] file = "res://midi/Tetris - Song A.mid" +channel_mute = [ false, true, false, false, false, false, false, true, true, true, true, false, false, false, false, false ] volume_db = -3 loop = true -soundfont = "res://midi/TimGM6mb.sf2" +loop_start = 2 +soundfont = "res://midi/FluidR3 GM.sf2" [node name="MoveDelay" type="Timer" parent="MidiPlayer" index="1"] @@ -106,11 +108,11 @@ wait_time = 0.1 one_shot = true autostart = false -[node name="LineLcearDelay" type="Timer" parent="MidiPlayer" index="2"] +[node name="LineCLearTimer" type="Timer" parent="MidiPlayer" index="2"] process_mode = 1 -wait_time = 0.86 -one_shot = false +wait_time = 1.41 +one_shot = true autostart = false [connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"] @@ -125,6 +127,6 @@ autostart = false [connection signal="timeout" from="MidiPlayer/MoveDelay" to="." method="_on_MoveDelay_timeout"] -[connection signal="timeout" from="MidiPlayer/LineLcearDelay" to="." method="_on_LineLcearDelay_timeout"] +[connection signal="timeout" from="MidiPlayer/LineCLearTimer" to="." method="_on_LineCLearTimer_timeout"] diff --git a/Mino/Mino.tscn b/Mino/Mino.tscn index c3216d8..72f4bd9 100644 --- a/Mino/Mino.tscn +++ b/Mino/Mino.tscn @@ -132,7 +132,7 @@ lod_min_hysteresis = 0.0 lod_max_distance = 0.0 lod_max_hysteresis = 0.0 emitting = false -amount = 20 +amount = 4 lifetime = 0.1 one_shot = false preprocess = 0.0 diff --git a/Mino/TrailMaterial.tres b/Mino/TrailMaterial.tres index c32282e..bcb8f91 100644 --- a/Mino/TrailMaterial.tres +++ b/Mino/TrailMaterial.tres @@ -23,7 +23,7 @@ params_point_size = 1.0 params_billboard_mode = 0 params_grow = false params_use_alpha_scissor = false -albedo_color = Color( 0.601563, 0.775878, 1, 0.00392157 ) +albedo_color = Color( 0.601563, 0.775878, 1, 0.0196078 ) metallic = 0.68 metallic_specular = 1.0 metallic_texture_channel = 0 diff --git a/WorldEnvironment.tscn b/WorldEnvironment.tscn index 12fe401..5977bf4 100644 --- a/WorldEnvironment.tscn +++ b/WorldEnvironment.tscn @@ -89,7 +89,7 @@ adjustment_contrast = 1.0 adjustment_saturation = 0.34 _sections_unfolded = [ "Adjustments", "Ambient Light", "Background", "Fog", "Resource" ] -[node name="WorldEnvironment" type="WorldEnvironment" index="0"] +[node name="WorldEnvironment" type="WorldEnvironment"] environment = SubResource( 2 ) diff --git a/midi/MidiPlayer.gd b/midi/MidiPlayer.gd index 98b9f55..405191a 100644 --- a/midi/MidiPlayer.gd +++ b/midi/MidiPlayer.gd @@ -38,7 +38,9 @@ var audio_stream_players = [] var _used_program_numbers = [] -var play_later_events = {2: {}, 6:{}, 10:{}} +var line_clear_notes = {2: {}, 6: {}} +var line_clear_notes_to_stop +var paused_position = 0 signal changed_tempo( tempo ) signal appeared_lyric( lyric ) @@ -47,6 +49,7 @@ signal appeared_cue_point( cue_point ) signal looped func _ready( ): + self._prepare_to_play( ) if self.playing: self.play( ) @@ -184,7 +187,6 @@ func _init_channel( ): @param from_position """ func play( from_position = 0 ): - self._prepare_to_play( ) self.playing = true self.seek( from_position ) @@ -276,13 +278,13 @@ func _process_track( ): match event.type: SMF.MIDIEventType.note_off: + if event_chunk.channel_number in line_clear_notes: + line_clear_notes[event_chunk.channel_number].erase(event.note) self._process_track_event_note_off( channel, event ) - if event_chunk.channel_number in play_later_events: - play_later_events[event_chunk.channel_number].erase(event.note) SMF.MIDIEventType.note_on: + if event_chunk.channel_number in line_clear_notes: + line_clear_notes[event_chunk.channel_number][event.note] = event self._process_track_event_note_on( channel, event ) - if event_chunk.channel_number in play_later_events: - play_later_events[event_chunk.channel_number][event.note] = event SMF.MIDIEventType.program_change: channel.program = event.number SMF.MIDIEventType.control_change: @@ -295,11 +297,6 @@ func _process_track( ): _: # 無視 pass - -func play_now(): - for channel in play_later_events: - for note in play_later_events[channel]: - _process_track_event_note_on( channel_status[channel], play_later_events[channel][note] ) func _process_track_event_note_off( channel, event ): var key_number = event.note + self.key_shift @@ -409,3 +406,19 @@ func get_now_playing_polyphony( ): if audio_stream_player.playing: polyphony += 1 return polyphony + + + +func resume(): + play(position) + +func play_line_clear(): + line_clear_notes_to_stop = {2: {}, 6:{}} + for channel in line_clear_notes: + for note in line_clear_notes[channel]: + _process_track_event_note_on(channel_status[channel], line_clear_notes[channel][note]) + line_clear_notes_to_stop[channel][note] = line_clear_notes[channel][note] + +func mute_midi_channels(channels, muted): + for channel_id in channels: + channel_mute[channel_id] = muted \ No newline at end of file diff --git a/midi/Tetris - Song A.mid b/midi/Tetris - Song A.mid index 5c1ba9c..a3bfc6f 100644 Binary files a/midi/Tetris - Song A.mid and b/midi/Tetris - Song A.mid differ diff --git a/project.godot b/project.godot index c008403..0c1c97c 100644 --- a/project.godot +++ b/project.godot @@ -52,6 +52,6 @@ rotate_clockwise=[ Object(InputEventJoypadButton,"resource_local_to_scene":false , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null) ] rotate_counterclockwise=[ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777224,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null) ]