diff --git a/src/main.py b/src/main.py index 2c8ca6b..9daed67 100644 --- a/src/main.py +++ b/src/main.py @@ -23,30 +23,6 @@ if __name__ == "__main__": *librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate), name="120 bpm amen break.mp3" )) - drum_channel.chunks.append(AudioChannelChunk( - drum_channel, - position=1, - *librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate), - name="120 bpm amen break.mp3" - )) - drum_channel.chunks.append(AudioChannelChunk( - drum_channel, - position=2, - *librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate), - name="120 bpm amen break.mp3" - )) - drum_channel.chunks.append(AudioChannelChunk( - drum_channel, - position=3, - *librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate), - name="120 bpm amen break.mp3" - )) - drum_channel.chunks.append(AudioChannelChunk( - drum_channel, - position=4, - *librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate), - name="120 bpm amen break.mp3" - )) piano_channel = ProjectChannel( test_project, @@ -65,9 +41,9 @@ if __name__ == "__main__": test_project.channels.append(piano_channel) test_project.write_to_file("test_project.tdp")""" - test_project = Project()#.from_file("test_project.tdp") + #test_project = Project.from_file("test_project.tdp") # start the ui print("Starting UI...") - app = AppUI(test_project) + app = AppUI(Project()) app.run() \ No newline at end of file diff --git a/src/test_project.tdp b/src/test_project.tdp index 8840da7..95f18c8 100644 Binary files a/src/test_project.tdp and b/src/test_project.tdp differ diff --git a/src/ui/app.py b/src/ui/app.py index 844e7a7..d89e0fc 100644 --- a/src/ui/app.py +++ b/src/ui/app.py @@ -10,7 +10,8 @@ from ui.widgets.project_settings import ProjectSettings from ui.widgets.channel import Channel from ui.widgets.context_menu import ContextMenu, NoSelectStatic -from project import ProjectChannel, Project +from project import ProjectChannel, Project, ChunkType +from ui.widgets.chunk_types.audio import AudioChunk, Chunk class AppUI(App): @@ -71,8 +72,9 @@ class AppUI(App): self.push_screen(FileSave( filters=Filters( - ("Any", lambda _: True), - ("TerminalDAW Project File", lambda p: p.suffix.lower() == ".tdp") + ("TerminalDAW Project File", lambda p: p.suffix.lower() == ".tdp"), + ("Any", lambda _: True) + ) ), callback=callback) @@ -113,6 +115,7 @@ class AppUI(App): row.styles.width = timeline.bar_offset * self.project.song_length + rows.mount(row) for chunk in channel.chunks: @@ -121,14 +124,14 @@ class AppUI(App): elif chunk.chunk_type == ChunkType.AUDIO: row.mount(AudioChunk(chunk.audio_data, chunk.sample_rate, chunk.name, chunk.position)) - rows.mount(row) self.notify(f"Loaded \"{path}\"") self.push_screen(FileOpen( filters=Filters( - ("Any", lambda _: True), - ("TerminalDAW Project File", lambda p: p.suffix.lower() == ".tdp") + ("TerminalDAW Project File", lambda p: p.suffix.lower() == ".tdp"), + ("Any", lambda _: True) + ) ), callback=callback) diff --git a/src/ui/widgets/channel.py b/src/ui/widgets/channel.py index ddc18d6..292e84f 100644 --- a/src/ui/widgets/channel.py +++ b/src/ui/widgets/channel.py @@ -57,6 +57,7 @@ class Channel(VerticalGroup): self.solo = solo self.pan = pan self.volume = volume + print(self.channel_name) def on_checkbox_changed(self, event: Checkbox.Changed): if event.checkbox.id == "mute": diff --git a/src/ui/widgets/chunk_types/audio.py b/src/ui/widgets/chunk_types/audio.py index 2d72ccb..f282043 100644 --- a/src/ui/widgets/chunk_types/audio.py +++ b/src/ui/widgets/chunk_types/audio.py @@ -86,7 +86,7 @@ class AudioChunk(Chunk): # get the decibel values from that y = librosa.amplitude_to_db(rms, ref=np.min) - + print(x) plot.bar( x, y, diff --git a/src/ui/widgets/sidebar.py b/src/ui/widgets/sidebar.py index bf22c23..aa2df5e 100644 --- a/src/ui/widgets/sidebar.py +++ b/src/ui/widgets/sidebar.py @@ -32,6 +32,7 @@ class Sidebar(Vertical): for i, channel in enumerate(self.app.project.channels): yield Channel( i, + channel, channel.name, channel.mute, channel.solo, diff --git a/src/ui/widgets/timeline.py b/src/ui/widgets/timeline.py index 0afed20..3a15c47 100644 --- a/src/ui/widgets/timeline.py +++ b/src/ui/widgets/timeline.py @@ -83,7 +83,7 @@ class Timeline(Vertical): self.app.zoom_level += (self.app.scroll_sensitivity_x / 200) self.calc_bar_offset() self.app.last_zoom_level = self.app.zoom_level - self.handle_zoom() + await self.handle_zoom() @on(events.MouseScrollUp) async def mouse_scroll_up(self, event: events.MouseScrollUp): @@ -92,7 +92,7 @@ class Timeline(Vertical): if self.app.zoom_level != self.app.last_zoom_level: self.app.last_zoom_level = self.app.zoom_level self.calc_bar_offset() - self.handle_zoom() + await self.handle_zoom() @on(events.MouseDown) async def mouse_down(self, event: events.MouseDown): @@ -107,7 +107,7 @@ class Timeline(Vertical): # seek to number of seconds self.song_player.seek(seconds) - def handle_zoom(self): + async def handle_zoom(self): for chunk in self.query(Chunk): chunk.calculate_size() chunk.update_offset(self) @@ -119,10 +119,16 @@ class Timeline(Vertical): if self.app.zoom_level >= 0.09 and bar_line.has_class("beat-line"): bar_line.display = False else: - bar_line.display = True + if self.app.zoom_level < 0.18: + bar_line.display = True + else: + if bar_line.has_class("bar-line") and bar_line.index % 16 == 0: + bar_line.display = True + else: + bar_line.display = False if self.song_player.paused and self.song_player.project: - self.run_worker(self.song_player.update_visual_playhead()) + await self.song_player.update_visual_playhead() def compose(self) -> ComposeResult: