Skip to content

Commit

Permalink
Use natural decay for voices, allow holding voices that support that …
Browse files Browse the repository at this point in the history
…in the example app

Also does a bit of a cleanup in the voice manager,
removing unrelated details.
  • Loading branch information
YuriSizov committed Nov 12, 2024
1 parent f450900 commit bca9cb7
Show file tree
Hide file tree
Showing 4 changed files with 515 additions and 511 deletions.
12 changes: 8 additions & 4 deletions example/globals/MusicPlayer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func _update_instrument() -> void:
_active_instrument.type = voice_data.type
_active_instrument.category = voice_data.category
_active_instrument.name = voice_data.name
_active_instrument.palette = voice_data.palette
_active_instrument.voice_held = voice_data.held

if _active_instrument.type == 0: # Drumkits don't use presets.
_active_instrument.voice = Controller.voice_manager.get_voice_preset(voice_data.preset)
Expand Down Expand Up @@ -197,11 +197,11 @@ func start_streaming() -> void:
print("Driver is streaming.")


func play_note(note: int, length: int) -> void:
func play_note(note: int) -> void:
# All instruments, except drumkits.
if _active_instrument.type == 0:
_active_instrument.update_filter()
_driver.note_on(note, _active_instrument.voice, length)
_driver.note_on(note, _active_instrument.voice)

# Drumkits.
else:
Expand All @@ -211,4 +211,8 @@ func play_note(note: int, length: int) -> void:

active_drumkit.update_filter(_active_instrument.cutoff, _active_instrument.resonance)
active_drumkit.update_volume(_active_instrument.volume)
_driver.note_on(active_drumkit.voice_note[note], active_drumkit.voice_list[note], length)
_driver.note_on(active_drumkit.voice_note[note], active_drumkit.voice_list[note])


func stop_note(note: int) -> void:
_driver.note_off(note)
Loading

0 comments on commit bca9cb7

Please sign in to comment.