Skip to content

Commit

Permalink
Address ruff checks, general code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwhitehead committed Aug 14, 2024
1 parent c1abe66 commit c22bb89
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/tinysoundfont/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from .synth import Synth, SoundFontException
from .sequencer import Sequencer
from .synth import (
Synth as Synth,
SoundFontException as SoundFontException,
)
from .sequencer import (
Sequencer as Sequencer,
)
2 changes: 1 addition & 1 deletion src/tinysoundfont/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import time

from .synth import Synth, SoundFontException
from .synth import Synth
from .sequencer import Sequencer


Expand Down
2 changes: 1 addition & 1 deletion src/tinysoundfont/midi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def load_memory(
event.t += delta_time
event.persistent = persistent
if filter is not None:
if filter(event) == True:
if filter(event):
event = None
# Check for None return value in filtered events, don't add if None
if event is not None:
Expand Down
3 changes: 1 addition & 2 deletions src/tinysoundfont/sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
#

from collections import deque
from typing import Callable, List, Optional
from typing import List
from .synth import Synth
from .midi import (
load,
Event,
Action,
NoteOn,
NoteOff,
ControlChange,
Expand Down
2 changes: 1 addition & 1 deletion test/example_midi_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def filter_program_change(event):
"""Make all program changes go to preset 19"""
match event.action:
case tinysoundfont.midi.ProgramChange(program):
case tinysoundfont.midi.ProgramChange(_program):
event.action.program = 19 # Church organ

seq = tinysoundfont.Sequencer(synth)
Expand Down
4 changes: 2 additions & 2 deletions test/test_synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_0():
def filter_program_change(event):
"""Make all program changes go to preset 40 (violin)"""
match event.action:
case tinysoundfont.midi.ProgramChange(program):
case tinysoundfont.midi.ProgramChange(_program):
event.program = 40
seq = tinysoundfont.Sequencer(synth)
seq.midi_load("test/1080-c01.mid", filter=filter_program_change)
Expand All @@ -90,7 +90,7 @@ def test_midi_generate():
import numpy as np

synth = tinysoundfont.Synth()
sfid = synth.sfload("test/florestan-subset.sfo")
_sfid = synth.sfload("test/florestan-subset.sfo")

seq = tinysoundfont.Sequencer(synth)
seq.midi_load("test/1080-c01.mid")
Expand Down

0 comments on commit c22bb89

Please sign in to comment.