1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

Piano: Start working on a desktop piano.

The idea here is to implement a simple synhesizer that allows you to play
music with your keyboard. :^)

It's a huge hack currently but we can improve upon this.
This commit is contained in:
Andreas Kling 2019-07-13 17:05:16 +02:00
parent f712ead1fb
commit c962c54610
7 changed files with 531 additions and 0 deletions

View file

@ -0,0 +1,35 @@
#include "Music.h"
#include "PianoWidget.h"
#include <LibCore/CFile.h>
#include <LibGUI/GApplication.h>
#include <LibGUI/GEventLoop.h>
#include <LibGUI/GWindow.h>
int main(int argc, char** argv)
{
CFile audio("/dev/audio");
if (!audio.open(CIODevice::WriteOnly)) {
dbgprintf("Can't open audio device: %s", audio.error_string());
return 1;
}
GApplication app(argc, argv);
auto* window = new GWindow;
window->set_title("Piano");
window->set_rect(100, 100, 512, 512);
auto* piano_widget = new PianoWidget;
window->set_main_widget(piano_widget);
window->show();
for (;;) {
GEventLoop::current().pump(GEventLoop::WaitMode::PollForEvents);
u8 buffer[4096];
piano_widget->fill_audio_buffer(buffer, sizeof(buffer));
audio.write(buffer, sizeof(buffer));
}
return 0;
}