project loading fixes, also some zoom improvements
This commit is contained in:
28
src/main.py
28
src/main.py
@@ -23,30 +23,6 @@ if __name__ == "__main__":
|
|||||||
*librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate),
|
*librosa.load("120 bpm amen break.mp3", mono=False, sr=test_project.sample_rate),
|
||||||
name="120 bpm amen break.mp3"
|
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(
|
piano_channel = ProjectChannel(
|
||||||
test_project,
|
test_project,
|
||||||
@@ -65,9 +41,9 @@ if __name__ == "__main__":
|
|||||||
test_project.channels.append(piano_channel)
|
test_project.channels.append(piano_channel)
|
||||||
|
|
||||||
test_project.write_to_file("test_project.tdp")"""
|
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
|
# start the ui
|
||||||
print("Starting UI...")
|
print("Starting UI...")
|
||||||
app = AppUI(test_project)
|
app = AppUI(Project())
|
||||||
app.run()
|
app.run()
|
||||||
Binary file not shown.
@@ -10,7 +10,8 @@ from ui.widgets.project_settings import ProjectSettings
|
|||||||
from ui.widgets.channel import Channel
|
from ui.widgets.channel import Channel
|
||||||
from ui.widgets.context_menu import ContextMenu, NoSelectStatic
|
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):
|
class AppUI(App):
|
||||||
@@ -71,8 +72,9 @@ class AppUI(App):
|
|||||||
|
|
||||||
self.push_screen(FileSave(
|
self.push_screen(FileSave(
|
||||||
filters=Filters(
|
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)
|
), callback=callback)
|
||||||
|
|
||||||
@@ -113,6 +115,7 @@ class AppUI(App):
|
|||||||
|
|
||||||
|
|
||||||
row.styles.width = timeline.bar_offset * self.project.song_length
|
row.styles.width = timeline.bar_offset * self.project.song_length
|
||||||
|
rows.mount(row)
|
||||||
|
|
||||||
for chunk in channel.chunks:
|
for chunk in channel.chunks:
|
||||||
|
|
||||||
@@ -121,14 +124,14 @@ class AppUI(App):
|
|||||||
elif chunk.chunk_type == ChunkType.AUDIO:
|
elif chunk.chunk_type == ChunkType.AUDIO:
|
||||||
row.mount(AudioChunk(chunk.audio_data, chunk.sample_rate, chunk.name, chunk.position))
|
row.mount(AudioChunk(chunk.audio_data, chunk.sample_rate, chunk.name, chunk.position))
|
||||||
|
|
||||||
rows.mount(row)
|
|
||||||
|
|
||||||
self.notify(f"Loaded \"{path}\"")
|
self.notify(f"Loaded \"{path}\"")
|
||||||
|
|
||||||
self.push_screen(FileOpen(
|
self.push_screen(FileOpen(
|
||||||
filters=Filters(
|
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)
|
), callback=callback)
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class Channel(VerticalGroup):
|
|||||||
self.solo = solo
|
self.solo = solo
|
||||||
self.pan = pan
|
self.pan = pan
|
||||||
self.volume = volume
|
self.volume = volume
|
||||||
|
print(self.channel_name)
|
||||||
|
|
||||||
def on_checkbox_changed(self, event: Checkbox.Changed):
|
def on_checkbox_changed(self, event: Checkbox.Changed):
|
||||||
if event.checkbox.id == "mute":
|
if event.checkbox.id == "mute":
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class AudioChunk(Chunk):
|
|||||||
# get the decibel values from that
|
# get the decibel values from that
|
||||||
y = librosa.amplitude_to_db(rms, ref=np.min)
|
y = librosa.amplitude_to_db(rms, ref=np.min)
|
||||||
|
|
||||||
|
print(x)
|
||||||
plot.bar(
|
plot.bar(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class Sidebar(Vertical):
|
|||||||
for i, channel in enumerate(self.app.project.channels):
|
for i, channel in enumerate(self.app.project.channels):
|
||||||
yield Channel(
|
yield Channel(
|
||||||
i,
|
i,
|
||||||
|
channel,
|
||||||
channel.name,
|
channel.name,
|
||||||
channel.mute,
|
channel.mute,
|
||||||
channel.solo,
|
channel.solo,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Timeline(Vertical):
|
|||||||
self.app.zoom_level += (self.app.scroll_sensitivity_x / 200)
|
self.app.zoom_level += (self.app.scroll_sensitivity_x / 200)
|
||||||
self.calc_bar_offset()
|
self.calc_bar_offset()
|
||||||
self.app.last_zoom_level = self.app.zoom_level
|
self.app.last_zoom_level = self.app.zoom_level
|
||||||
self.handle_zoom()
|
await self.handle_zoom()
|
||||||
|
|
||||||
@on(events.MouseScrollUp)
|
@on(events.MouseScrollUp)
|
||||||
async def mouse_scroll_up(self, event: 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:
|
if self.app.zoom_level != self.app.last_zoom_level:
|
||||||
self.app.last_zoom_level = self.app.zoom_level
|
self.app.last_zoom_level = self.app.zoom_level
|
||||||
self.calc_bar_offset()
|
self.calc_bar_offset()
|
||||||
self.handle_zoom()
|
await self.handle_zoom()
|
||||||
|
|
||||||
@on(events.MouseDown)
|
@on(events.MouseDown)
|
||||||
async def mouse_down(self, event: events.MouseDown):
|
async def mouse_down(self, event: events.MouseDown):
|
||||||
@@ -107,7 +107,7 @@ class Timeline(Vertical):
|
|||||||
# seek to number of seconds
|
# seek to number of seconds
|
||||||
self.song_player.seek(seconds)
|
self.song_player.seek(seconds)
|
||||||
|
|
||||||
def handle_zoom(self):
|
async def handle_zoom(self):
|
||||||
for chunk in self.query(Chunk):
|
for chunk in self.query(Chunk):
|
||||||
chunk.calculate_size()
|
chunk.calculate_size()
|
||||||
chunk.update_offset(self)
|
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"):
|
if self.app.zoom_level >= 0.09 and bar_line.has_class("beat-line"):
|
||||||
bar_line.display = False
|
bar_line.display = False
|
||||||
else:
|
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:
|
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:
|
def compose(self) -> ComposeResult:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user