Skip to content

Commit

Permalink
Merge pull request #67 from cclauss/ruff-rules-for-whitespace
Browse files Browse the repository at this point in the history
Ruff rules for whitespace
  • Loading branch information
nwhitehead authored May 14, 2024
2 parents 7dffe78 + aeea57c commit 6417932
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 64 deletions.
84 changes: 42 additions & 42 deletions test/sequencerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,54 @@
seqduration = 1000

def schedule_next_callback():
# I want to be called back before the end of the next sequence
callbackdate = int(now + seqduration/2)
sequencer.timer(callbackdate, dest=mySeqID)
# I want to be called back before the end of the next sequence
callbackdate = int(now + seqduration/2)
sequencer.timer(callbackdate, dest=mySeqID)

def schedule_next_sequence():
global now
# the sequence to play
# the beat : 2 beats per sequence
sequencer.note(int(now + seqduration * 1/2), 0, 60, duration=250, velocity=80, dest=synthSeqID)
sequencer.note(int(now + seqduration * 2/2), 0, 60, duration=250, velocity=80, dest=synthSeqID)
# melody
sequencer.note(int(now + seqduration*1/10), 1, 45, duration=250, velocity=int(127*2/3), dest=synthSeqID)
sequencer.note(int(now + seqduration*4/10), 1, 50, duration=250, velocity=int(127*2/3), dest=synthSeqID)
sequencer.note(int(now + seqduration*8/10), 1, 55, duration=250, velocity=int(127*3/3), dest=synthSeqID)
# so that we are called back early enough to schedule the next sequence
schedule_next_callback()
now = now + seqduration
global now
# the sequence to play
# the beat : 2 beats per sequence
sequencer.note(int(now + seqduration * 1/2), 0, 60, duration=250, velocity=80, dest=synthSeqID)
sequencer.note(int(now + seqduration * 2/2), 0, 60, duration=250, velocity=80, dest=synthSeqID)
# melody
sequencer.note(int(now + seqduration*1/10), 1, 45, duration=250, velocity=int(127*2/3), dest=synthSeqID)
sequencer.note(int(now + seqduration*4/10), 1, 50, duration=250, velocity=int(127*2/3), dest=synthSeqID)
sequencer.note(int(now + seqduration*8/10), 1, 55, duration=250, velocity=int(127*3/3), dest=synthSeqID)
# so that we are called back early enough to schedule the next sequence
schedule_next_callback()

now = now + seqduration

def seq_callback(time, event, seq, data):
schedule_next_sequence()
schedule_next_sequence()

def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join

return join(dirname(__file__), file_name)
return join(dirname(__file__), file_name)

if __name__=="__main__":
global sequencer, fs, mySeqID, synthSeqID, now
fs = fluidsynth.Synth()
fs.start()
# you might have to use other drivers:
#fs.start(driver="alsa", midi_driver="alsa_seq")

sfid = fs.sfload(local_file_path("example.sf2"))
fs.program_select(0, sfid, 0, 0)
fs.program_select(1, sfid, 0, 0) # use the same program for channel 2 for cheapness

sequencer = fluidsynth.Sequencer()
synthSeqID = sequencer.register_fluidsynth(fs)
mySeqID = sequencer.register_client("mycallback", seq_callback)
now = sequencer.get_tick()
schedule_next_sequence()
time.sleep(10)
sequencer.delete()
fs.delete()
global sequencer, fs, mySeqID, synthSeqID, now
fs = fluidsynth.Synth()
fs.start()
# you might have to use other drivers:
# fs.start(driver="alsa", midi_driver="alsa_seq")

sfid = fs.sfload(local_file_path("example.sf2"))
fs.program_select(0, sfid, 0, 0)
fs.program_select(1, sfid, 0, 0) # use the same program for channel 2 for cheapness

sequencer = fluidsynth.Sequencer()
synthSeqID = sequencer.register_fluidsynth(fs)
mySeqID = sequencer.register_client("mycallback", seq_callback)
now = sequencer.get_tick()
schedule_next_sequence()

time.sleep(10)

sequencer.delete()
fs.delete()
10 changes: 5 additions & 5 deletions test/test1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import fluidsynth

def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join

return join(dirname(__file__), file_name)
return join(dirname(__file__), file_name)

fs = fluidsynth.Synth()
fs.start()
Expand Down
14 changes: 7 additions & 7 deletions test/test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import fluidsynth

def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join

return join(dirname(__file__), file_name)
return join(dirname(__file__), file_name)

pa = pyaudio.PyAudio()
strm = pa.open(
format = pyaudio.paInt16,
channels = 2,
rate = 44100,
channels = 2,
rate = 44100,
output = True)

s = []
Expand Down
10 changes: 5 additions & 5 deletions test/test3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import fluidsynth

def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join

return join(dirname(__file__), file_name)
return join(dirname(__file__), file_name)

fs = fluidsynth.Synth()
fs.start()
Expand Down
10 changes: 5 additions & 5 deletions test/test4.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import fluidsynth

def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join
"""
Return a file path to a file that is in the same directory as this file.
"""
from os.path import dirname, join

return join(dirname(__file__), file_name)
return join(dirname(__file__), file_name)

fs = fluidsynth.Synth()
fs.start()
Expand Down

0 comments on commit 6417932

Please sign in to comment.