summaryrefslogtreecommitdiff
path: root/Applications/Piano
AgeCommit message (Collapse)Author
2020-02-27Piano: New timing system and zoomable piano rollWilliam McPherson
This patch allows roll notes to be of different sizes. This necessitates a new internal representation of time. BPM and time signatures are mostly implemented but not exposed. Roll notes are now sample-accurate and the grid is aligned to 60 BPM 4/4. The roll is divided by the time signature raised to some power of 2, giving the musical divisions of (in the case of 4/4) 16, 32, 64 etc. Before, our timing was derived from the buffer size and we relied on that to implement delay. Delay has been rewritten to be sample-granular. It's now exposed as the proper "divisions of a beat". Something to be wary of is that the last buffer in the loop is also used for the start of the next loop. In other words, we loop mid-buffer. This means we write WAVs with a tiny bit of silence due to breaking the loop after filling half a buffer. The data structure for the roll is an array of SinglyLinkedLists of RollNotes. Separating by pitch (via the array layout) makes insertion much simpler and faster. Using sorted lists (and thus SinglyLinkedListIterators) to do lookups is very quick as you know the sample of the next note and can just compare it to the current sample. I implemented this with HashMaps and the cost of lookups was abysmal. I also tried a single SinglyLinkedList and the insertion code got even more complicated than it already is.
2020-02-25AK: Make Queue use size_t for its sizeAndreas Kling
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-23LibGUI: Add helper for constructing new TabWidget tabsAndreas Kling
This patch adds the following convenience helper: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = tab_widget->add_tab<GUI::Widget>("My tab", ...); The above is equivalent to: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = GUI::Widget::construct(...); tab_widget->add_widget("My tab", my_widget);
2020-02-23LibGUI: Make GUI::Frame have the 2px sunken container look by defaultAndreas Kling
The overwhelming majority of GUI::Frame users set the same appearance, so let's just make it the default.
2020-02-23Userspace: Use Core::Object::add() when building interfacesAndreas Kling
2020-02-16Piano: Set step property for ADSR slidersTibor Nagy
2020-02-16LibGUI: Add forwarding headerAndreas Kling
This patch adds <LibGUI/Forward.h> and uses it a bunch. It also dragged various header dependency reduction changes into it.
2020-02-15LibGUI: Reduce menu-related header dependenciesAndreas Kling
2020-02-10LibAudio/Piano: Replace floats with doublesWilliam McPherson
We should default to double-precision so that clients can make the choice to use float or double.
2020-02-10Piano: Draw stereo wavesWilliam McPherson
Draw two waves in different colors.
2020-02-10Piano: Try to be more stereo-orientedWilliam McPherson
2020-02-10Piano: Add nice scale factor to WaveWidgetWilliam McPherson
2020-02-10Piano: Ensure WaveWidget paints in-boundsWilliam McPherson
Letting GUI::Frame::paint_event() cover up your mistakes is tacky :P
2020-02-10Piano: Put reset() with other settersWilliam McPherson
2020-02-10Piano: Add samplerWilliam McPherson
This commit adds basic support for importing, viewing and playing WAV samples at different pitches. Naming issues: - We are using the Sample struct from Music.h, but also the Sample struct from LibAudio (Audio::Sample). This is a little confusing. set_recorded_sample() finds the peak sample and then divides all the samples by that peak to get a guaranteed min/max of -1/1. This is nice because our other waves are also bound between these values and we can just do the same stuff. This is why we're using Audio::Sample, because it uses floats, whereas Music.h's Sample uses i16s. It's a little annoying that we have to use a mixture of floats and doubles though. For playback at lower frequencies, we're calculating in-between samples, rather than just playing samples multiple times. Basically, you get the current sample and add the difference between the current sample and the next sample multiplied by the distance from the current sample. This is like drawing the hypotenuse of a right-angled triangle.
2020-02-06LibGUI: Remove leading G from filenamesAndreas Kling
2020-02-06Piano: Add export actionWilliam McPherson
This is a pretty rudimentary WAV export function for Piano.
2020-02-06Piano: Fix roll playback at startupWilliam McPherson
This is not a bug currently, since the first column immediately starts playing at startup and leaves no time for the user to put notes in it. However, this is needed for exporting.
2020-02-06Piano: Move piano roll internals to AudioEngineWilliam McPherson
The piano roll data definitely belongs in AudioEngine along with the note and time data. Now RollWidget only has GUI information, much like the other widgets. Note that this commit exacerbates issue #1158 which is caused by RollWidget::paint_event().
2020-02-06LibAudio: Remove leading A from filenamesAndreas Kling
2020-02-06LibCore: Remove leading C from filenamesAndreas Kling
2020-02-06LibGUI: Rename {H,V}BoxLayout => {Horizontal,Vertical}BoxLayoutAndreas Kling
2020-02-06LibGUI: Add HorizontalSlider and VerticalSlider convenience classesAndreas Kling
2020-02-06LibGfx: Prefer using Gfx::Bitmap::load_from_file instead of load_png()Andreas Kling
Code that just wants to open a Gfx::Bitmap from a file should not be calling the PNG codec directly.
2020-02-06LibGfx: Unpublish Gfx::Point from global namespaceAndreas Kling
2020-02-06LibGfx: Unpublish Gfx::Rect from global namespaceAndreas Kling
2020-02-06LibGfx: Rename from LibDraw :^)Andreas Kling
2020-02-06LibDraw: Put all classes in the Gfx namespaceAndreas Kling
I started adding things to a Draw namespace, but it somehow felt really wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename the library to LibGfx. :^)
2020-02-06LibAudio: Put all classes in the Audio namespace and remove leading AAndreas Kling
2020-02-05Piano: Fix building with clangjoshua stein
2020-02-05Piano: Set some nice defaultsWilliam McPherson
2020-02-05Piano: Add releaseWilliam McPherson
Notice that we are calculating release time according to the level when the note is turned off rather than the sustain level. Naively using the sustain level gives very long release times if you turn the note off during attack, whereas this deterministically gives the same release time.
2020-02-05Piano: Add attackWilliam McPherson
2020-02-05Piano: Add sustainWilliam McPherson
2020-02-05Piano: Make decay more accurateWilliam McPherson
1. Make decay sample-granular rather than buffer-granular You only have ~43 buffers per second which can make a jagged signal. 2. Calculate decay in milliseconds Decay is supposed to be a time value.
2020-02-05Piano: Remove phony multiple same note playbackWilliam McPherson
I say "phony" because it's not actually playing the same frequency twice, it's just playing the same frequency at a higher volume. We can properly implement this later but at the moment it'll get in the way of our ADSR implementation.
2020-02-05Piano: Fix default knob valuesWilliam McPherson
Now you can change the defaults in AudioEngine and not be totally confused. 1. The default for m_octave_knob was actually upside-down. 2. The default for m_decay_knob wasn't respecting AudioEngine. 3. The default for m_delay_knob wasn't respecting AudioEngine.
2020-02-02LibGUI: Put all classes in the GUI namespace and remove the leading GAndreas Kling
This took me a moment. Welcome to the new world of GUI::Widget! :^)
2020-02-02LibCore: Put all classes in the Core namespace and remove the leading CAndreas Kling
I've been wanting to do this for a long time. It's time we start being consistent about how this stuff works. The new convention is: - "LibFoo" is a userspace library that provides the "Foo" namespace. That's it :^) This was pretty tedious to convert and I didn't even start on LibGUI yet. But it's coming up next.
2020-02-02LibGUI: Add GHBoxLayout and GVBoxLayout convenience classesAndreas Kling
2020-01-31Piano: Rewrite applicationWilliam McPherson
Goals: - Switch to a more typical LibGUI arrangement - Separate GUI (MainWidget) and audio (AudioEngine) - Improve on existing features while retaining the same feature set Improvements: - Each GUI element is a separate widget - The wave (WaveWidget) scales with the window - The piano roll (RollWidget) scales horizontally and scrolls vertically - The piano (KeysWidget) fits as many notes as possible - The knobs (KnobsWidget) are now sliders - All mouse and key events are handled in constant time - The octave can be changed while playing notes - The same note can be played with the mouse, keyboard and roll at the same time, and the volume of the resulting note is scaled accordingly - Note frequency constants use the maximum precision available in a double
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-31Applications: Implement some missing MenuBars & AboutDialogsJami Kettunen
2019-12-25Piano: Factor wave rendering to its own functionWilliam McPherson
2019-12-25Piano: Use switch statements on m_wave_typeWilliam McPherson
2019-12-25Piano: Move m_front_buffer/m_back_buffer off heapWilliam McPherson
2019-12-25Piano: Initialize m_note_on[]William McPherson
This was being read before initialization.
2019-12-25Piano: Rename "release" to "decay"William McPherson
That's not release!
2019-12-25Piano: Initialize keys[] at member definitionWilliam McPherson