Commit graph

52 commits

Author SHA1 Message Date
Ben Wiederhake
0184fc5e43 Everywhere: Use AK_MAKE_DEFAULT_MOVABLE to avoid mistakes 2023-06-18 08:47:51 +01:00
kleines Filmröllchen
0ab19dc4cd Piano: Allow per-track controls (again)
This makes Piano exactly as usable as when I started the large refactor
some years ago, which *sounds* like I'm a terrible person but now it (1)
looks nicer and (2) has a flexible backend that can already deal with
aribtrary kinds of processors on any track.
2023-05-05 01:32:09 +02:00
Andreas Kling
689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
8a48246ed1 Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-06 23:46:35 +01:00
kleines Filmröllchen
1c3050245e LibDSP: Don't crash on out-of-bounds parameter value
We can just clamp instead.
2023-02-25 20:49:41 -07:00
Linus Groh
09d40bfbb2 Everywhere: Use _{short_,}string to create Strings from literals 2023-02-25 20:51:49 +01:00
kleines Filmröllchen
76b71fcb75 LibDSP: Get rid of DeprecatedString
This was a rather easy change, since only parameter names make use of
strings in the first place.

This also improves OOM resistance: If we can't create a parameter name,
we will just set it to the empty string.
2023-02-25 15:41:01 +01:00
Florian Kaiser
815442b2b5 Piano: Fix insertion and deletion of notes
On mouse move the pressed button is not present in the event argument
which causes the corresponding code to never fire. Instead it now stores
the original mouse down event and acts according to that on mouse move.
2023-02-15 12:58:25 +01:00
MacDue
63b11030f0 Everywhere: Use ReadonlySpan<T> instead of Span<T const> 2023-02-08 19:15:45 +00:00
Linus Groh
9c08bb9555 AK: Remove try_ prefix from FixedArray creation functions 2023-01-28 22:41:36 +01:00
Sam Atkins
2a699c904a LibDSP: Remove declarations for non-existent methods 2023-01-27 20:33:18 +00:00
Moustafa Raafat
ae2abcebbb Everywhere: Use C++ concepts instead of requires clauses 2022-12-09 11:25:30 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Linus Groh
d26aabff04 Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
kleines Filmröllchen
b29d27c948 LibDSP: Add a fixed mastering processor to Track
This processor will not appear in the normal processor chain later on,
but is used for final mixing of the track.
2022-07-25 15:25:13 +02:00
kleines Filmröllchen
ab2d8edcbb LibDSP: Remove Track volume getters and setters 2022-07-25 15:25:13 +02:00
kleines Filmröllchen
d5166ddbcf LibDSP: Actually implement the Mastering processor
This can now handle mute, volume control and panning.
2022-07-25 15:25:13 +02:00
kleines Filmröllchen
4941cffdd0 Piano+LibDSP: Move Track to LibDSP
This is a tangly commit and it fixes all the bugs that a plain move
would have caused (i.e. we need to touch other logic which had wrong
assumptions).
2022-07-22 19:35:41 +01:00
kleines Filmröllchen
00e13b5b27 LibDSP: Rename library namespace to DSP
That's the standard naming convention, but I didn't follow it when
originally creating LibDSP and nobody corrected me, so here I am one
year later :^)
2022-07-19 11:17:45 +01:00
kleines Filmröllchen
62c1ce4073 LibDSP: Fix keyboard glitch in Classic
This is quite elusive.
2022-05-26 10:24:43 +01:00
kleines Filmröllchen
37b340a698 LibDSP: Introduce the Keyboard
This is a class for handling user MIDI input, which is combined by the
Track with roll note data if applicable.
2022-05-26 10:24:43 +01:00
kleines Filmröllchen
9035d9e845 LibDSP+Piano: Convert DSP APIs to accept entire sample ranges
This has mainly performance benefits, so that we only need to call into
all processors once for every audio buffer segment. It requires
adjusting quite some logic in most processors and in Track, as we have
to consider a larger collection of notes and samples at each step.

There's some cautionary TODOs in the currently unused LibDSP tracks
because they don't do things properly yet.
2022-05-13 00:47:26 +02:00
kleines Filmröllchen
4d65607649 LibDSP: Remove Transport's time counter reference API
This is what the old Transport in Piano had, but as everyone just
references Transport directly, there's no need for it anymore.
2022-05-13 00:47:26 +02:00
kleines Filmröllchen
f23aea0c4b LibDSP: Make the note frequencies an AK::Array instead of a C array
This was a leftover from the early days of Piano, and there's no reason
to leave it that way especially if we want to use more complex
collection APIs in the future.
2022-05-13 00:47:26 +02:00
kleines Filmröllchen
bcb331b862 LibDSP: Improve const correctness 2022-05-13 00:47:26 +02:00
kleines Filmröllchen
4a6ebb8beb LibDSP: Refactor OOP non-functionally
* Don't inherit from Core::Object everywhere, that's overkill. Use
  RefCounted instead.
* Change some constructor visibilites to facilitate the above.
* default-implement all virtual destructors if possible.
* Drive-by include hygiene.
2022-05-13 00:47:26 +02:00
kleines Filmröllchen
19a4b820c4 LibAudio+LibDSP: Switch samples to 32-bit float instead of 64-bit float
This has been overkill from the start, and it has been bugging me for a
long time. With this change, we're probably a bit slower on most
platforms but save huge amounts of space with all in-memory sample
datastructures.
2022-05-07 20:20:16 +02:00
kleines Filmröllchen
ab49fcfb7c LibAudio+Userland: Remove Audio::LegacyBuffer
The file is now renamed to Queue.h, and the Resampler APIs with
LegacyBuffer are also removed. These changes look large because nobody
actually needs Buffer.h (or Queue.h). It was mostly transitive
dependencies on the massive list of includes in that header, which are
now almost all gone. Instead, we include common things like Sample.h
directly, which should give faster compile times as very few files
actually need Queue.h.
2022-05-03 23:09:20 +02:00
Hendiadyoin1
cd21e03225 AK+Everywhere: Add sincos and use it in some places
Calculating sin and cos at once is quite a bit cheaper than calculating
them individually.
x87 has even a dedicated instruction for it: `fsincos`.
2022-03-15 11:39:42 +01:00
Arne Elster
8185e7e932 LibDSP: Add windowing functions
Windows are used in many DSP related applications. A prominent use case
is spectral analysis, where windowing the signal before doing spectral
analysis mitigates spectral leakage.
2022-03-14 22:45:05 +01:00
kleines Filmröllchen
00dd8f8fbe LibDSP: Generalize & improve FFT
Several related improvements to our Fast Fourier Transform
implementation:
- FFT now operates on spans, allowing it to use many more container
  types other than Vector. It's intended anyways that FFT transmutes the
  input data.
- FFT is now constexpr, moving the implementation to the header and
  removing the cpp file. This means that if we have static collections
  of samples, we can transform them at compile time.
- sample_data.data() weirdness is now gone.
2022-03-14 22:45:05 +01:00
kleines Filmröllchen
e7d84da3da LibDSP: Allow ProcessorRangeParameter to specify if it's a log value
This doesn't affect the parameter's own behavior but is part of the
parameter meta-data, just as the name. If a parameter is logarithmic,
UI elements should represent it with an interface that scales
logarithmically.
2022-02-28 13:59:31 +01:00
Arne Elster
6a64aabce8 LibDSP: Add IMDCT
This implements a generic IMDCT to be used by the MP3 decoder.
2022-02-26 16:01:26 +01:00
kleines Filmröllchen
be6418cc50 Everywhere: Use my new serenityos.org e-mail :^) 2022-01-14 11:54:09 +01:00
Sam Atkins
a0f6da7ceb LibDSP: Cast unused smart-pointer return value to void 2021-12-05 15:31:03 +01:00
Brian Gianforcaro
55aecf5381 LibDSP: Fix potential slicing issue in volume_from_envelope
Use pointer or reference to avoid slicing from "PitchedEnvelope"
to "Envelope". This was found by SonarCloud.
2021-11-29 14:19:31 -08:00
kleines Filmröllchen
a099a77e82 SoundPlayer+LibDSP: Move the FFT implementation to LibDSP
LibDSP can greatly benefit from this nice FFT implementation, so let's
move it into the fitting library :^)

Note that this now requires linking SoundPlayer against LibDSP. That's
not an issue (LibDSP is rather small currently anyways), as we can
probably make great use of it in the future anyways.
2021-11-24 23:45:08 +00:00
kleines Filmröllchen
b14a64b3c8 Piano: Move to LibDSP's Classic synthesizer
Almost all synthesizer code in Piano is removed in favor of the LibDSP
reimplementation.

This causes some issues that mainly have to do with the way Piano
currently handles talking to LibDSP. Additionally, the sampler is gone
for now and will be reintroduced with future work.
2021-11-22 22:26:17 +01:00
kleines Filmröllchen
3ca059da2d LibDSP: Create Classic synth
The Classic synthesizer is a replication of Piano's old synthesizer
engine that is removed in the next commit.
2021-11-22 22:26:17 +01:00
kleines Filmröllchen
7663fbb19e LibDSP: Introduce ProcessorEnumParameter 2021-11-22 22:26:17 +01:00
kleines Filmröllchen
cc9aab7462 LibDSP: Add Envelope abstraction
For the upcoming synthesizer, having an abstracted ADSR envelope concept
is highly desirable. Additionally, Envelope is mostly constexpr and
therefore super fast :^)
2021-11-22 22:26:17 +01:00
Andreas Kling
216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
kleines Filmröllchen
8af97d0ce7 Audio: Fix code smells and issues found by static analysis
This fixes all current code smells, bugs and issues reported by
SonarCloud static analysis. Other issues are almost exclusively false
positives. This makes much code clearer, and some minor benefits in
performance or bug evasion may be gained.
2021-11-15 23:00:11 +00:00
kleines Filmröllchen
c2340a1b1f LibDSP: Optimize note processing
Previously, a collection of notes (Vector or Array) would be created and
promptly deleted for every sample (at least 44 thousand times per
second!). This was measured to be one of the most significant
performance drawbacks as well as the most obvious performance
improvement I could currently find here. Although it will not cause
Piano to lag currently (at least on virtualized systems), I see an
incoming issue once we get the capability to use more processors.

Now, we use a HashMap correlating pitches to notes, and Track reuses the
data structure in order to avoid reallocations. That is the reason for
introducing the fast clear_with_capacity to HashMap.
2021-11-11 09:19:17 +01:00
kleines Filmröllchen
557be4649d LibDSP: Move to constexpr wherever possible 2021-11-11 09:19:17 +01:00
kleines Filmröllchen
3a4ec49131 LibDSP: Clean up ProcessorParameter header 2021-11-11 09:19:17 +01:00
David Isaksson
b6d075bb01 LibAudio: Rename Audio::Frame -> Audio::Sample
"Frame" is an MPEG term, which is not only unintuitive but also
overloaded with different meaning by other codecs (e.g. FLAC).
Therefore, use the standard term Sample for the central audio structure.

The class is also extracted to its own file, because it's becoming quite
large. Bundling these two changes means not distributing similar
modifications (changing names and paths) across commits.

Co-authored-by: kleines Filmröllchen <malu.bertsch@gmail.com>
2021-11-08 16:29:25 -08:00
Ben Wiederhake
52a1ff4d4b LibDSP+Piano: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.

This commit is separate from the other Applications/Libraries changes
because it required additional adaption of the code. Note that the old
code did precisely what these changes try to prevent: Create and handle
a ref-counted object with a refcount of zero.
2021-11-02 22:56:53 +01:00
Brian Gianforcaro
69bc04d870 LibDSP: Remove unused Effects::Delay::m_old_delay_size member
SonarCloud flagged this as m_delay_buffer is technically uninitialized
at the point at which the POD types are initialized in a constructor.

I don't check to see if this was actually a real issue, as the member
is ultimately unused. So lets just get rid of it.
2021-09-28 10:58:09 +02:00