Skip to content

Commit 6a97373

Browse files
committed
Rename MusicStudio => Piano
1 parent d30bef6 commit 6a97373

16 files changed

Lines changed: 510 additions & 3 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.

Piano/Layout.h

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.

Piano/Playlist.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#pragma once
2+
#include <Ty/Id.h>
3+
#include <AU/Audio.h>
4+
#include <Ty/Vector.h>
5+
#include <Ty/View.h>
6+
#include <SoundIo/SoundIo.h>
7+
8+
struct TrackSlice {
9+
Id<AU::Audio> audio;
10+
u32 start_frame;
11+
u8 relative_end_beat;
12+
};
13+
14+
struct SoundSlice {
15+
TrackSlice* tracks;
16+
usize tracks_count;
17+
};
18+
19+
struct Playlist {
20+
SoundSlice* sound_slice_by_beat_slot;
21+
usize sound_slice_count;
22+
};
23+
24+
struct AudioCommand {
25+
Id<AU::Audio> audio;
26+
bool play;
27+
};
28+
29+
struct FrameContext {
30+
Playlist playlist;
31+
Vector<AudioCommand> commands;
32+
};
33+
34+
View<AudioCommand const> beat_command(FrameContext* context, usize beat);
35+
View<AudioCommand const> beat_command(FrameContext* context, usize beat)
36+
{
37+
context->commands.clear();
38+
auto playlist = context->playlist;
39+
usize current_slot = beat & 0xFFFFFFFFFFFFFF00;
40+
usize relative_beat = beat & 0xFF;
41+
if (current_slot > playlist.sound_slice_count) {
42+
return {};
43+
}
44+
auto sound_slice = playlist.sound_slice_by_beat_slot[current_slot];
45+
for (usize track_index = 0; track_index < sound_slice.tracks_count; track_index++) {
46+
auto track = sound_slice.tracks[track_index];
47+
auto play = track.relative_end_beat < relative_beat;
48+
MUST(context->commands.append({
49+
.audio = track.audio,
50+
.play = play,
51+
}));
52+
}
53+
return context->commands.view();
54+
}
55+
56+
void audio_scheduler(void)
57+
{
58+
auto ctx = FrameContext();
59+
auto audios = Vector<AU::Audio>();
60+
usize beats = 120;
61+
62+
SoundIoOutStream* streams[1024];
63+
64+
for (usize i = 0; i < beats; i++) {
65+
auto commands = beat_command(&ctx, i);
66+
for (auto command : commands) {
67+
auto* stream = streams[command.audio.raw()];
68+
soundio_outstream_pause(stream, !command.play);
69+
}
70+
}
71+
72+
// playlist.current_frame += frames;
73+
// playlist.current_beat_time +=
74+
}
File renamed without changes.

0 commit comments

Comments
 (0)