Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
10 changes: 5 additions & 5 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def normalize_audio(audio: np.ndarray) -> np.ndarray:
MAX_DURATION = 600 # Maximum duration of audio buffer in seconds


STATED_TEMPO = 220 # Tempo at which the user plans to play in BPM
SOURCE_TEMPO = 200 # Tempo at which the user actually plays in BPM
PIECE_NAME = 'greensleeves' # Name of piece
PROGAM_NUMBER = 0 # Program number for accompaniment instrument
SOLO_VOLUME_MULTIPLIER = 1
STATED_TEMPO = 100 # Tempo at which the user plans to play in BPM
SOURCE_TEMPO = 110 # Tempo at which the user actually plays in BPM
PIECE_NAME = 'air_on_the_g_string' # Name of piece
PROGAM_NUMBER = 42 # Program number for accompaniment instrument
SOLO_VOLUME_MULTIPLIER = 0.75

MIDI_SCORE = os.path.join('data', 'midi', PIECE_NAME + '.mid') # Path to MIDI file
OUTPUT_DIR = os.path.join('data', 'audio', PIECE_NAME) # Directory where synthesized audio will be saved
Expand Down
4 changes: 2 additions & 2 deletions backend/src/audio_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def generate_audio(self, output_dir, tempo: float = 120, sample_rate: int = 4410
# Example usage:
base_dir = Path(__file__).parent
score = os.path.join('data', 'midi', 'twinkle_twinkle.mid')
output_dir = os.path.join('data', 'audio', 'twinkle_twinkle', '200bpm')
output_dir = os.path.join('data', 'audio', 'twinkle_twinkle', '100bpm')
SAMPLE_RATE = 44100
TEMPO = 200
TEMPO = 100

try:
generator = AudioGenerator(score_path=score)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/midi_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def update_score_position(self, position: float):
Current position in beats (quarter-note units).
"""
self.score_position = position
self._next_note_index = 0
# self._next_note_index = 0

def _note_worker(self, midi_note: int, duration_sec: float):
"""
Expand Down Expand Up @@ -217,7 +217,7 @@ def _performance_loop(self):
while (self._next_note_index < len(self.notes) and
self.score_position >= self.notes[self._next_note_index][2]):
frequency, quarter_duration, quarter_offset = self.notes[self._next_note_index]
if (self.score_position - quarter_offset < .1 and self.last_beat is not quarter_offset):
if (self.score_position - quarter_offset < 1 and self.last_beat is not quarter_offset):
print(
f"Playing note at beat {quarter_offset}: {frequency:.2f} Hz, "
f"duration {quarter_duration} beats"
Expand Down