Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample Track Recording with Jack backend #7567

Open
wants to merge 86 commits into
base: master
Choose a base branch
from

Conversation

mmeeaallyynn
Copy link

This adds support for the Jack backend for recording Sample Tracks.

Based on #5990

Reflexe and others added 30 commits October 23, 2021 21:02
instead of hacking sampleBuffer ()->startFrame ().

That solves a bug with `startFrame ()` being negetive in recording some
cases.
Instead of hiding the record action buttons, disable them and indicate the issue on the tooltip.
…tage-one

Conflicts:
* src/core/SampleRecordHandle.cpp

Also fixed the setting of the font size in `SampleClipView::paintEvent`.
Move the recording symbol and the "Rec" string to the lower left of the
clip so that it does not overlap with the clip name if it is shown.

Make the "Rec" string translatable and increase the font size.
Up to now the SDL audio driver attempted to use the default recording
device. This might not be what users want or expect, especially since the
actually used device is not visible anywhere. So if recording does not
work for the users they have no way to find out what's wrong.

Extend the settings screen of the SDL driver with a combo box that allows
to select the input device to be used. Store the selected device name in
a new attribute called "inputdevice" in the "audiosdl" section of the
configuration file.

Use the information from the configuration when attempting to inialize
the input device. Fall back to the default device if that does not work.
Provide the setting "[System Default]" which instructs the SDL driver to
use the default device of the system as the input device. In the
configuration file this option is represented as an empty string. This
should play well with the current existing configuration of the users.
Let users configure the output device that's used by the SDL driver.
Code-wise the implementation is very similar to the input device
configuration.

Use a `QComboBox` instead of a `QLineEdit` for `m_device` and rename it
to `m_playbackDeviceComboBox`.

Rename `s_defaultInputDevice` to `s_systemDefaultDevice` because it is
used in the context of playback and input devices.
Make sure that labels are always shown by setting the row wrap policy of
the form layout to wrap long rows.
Rename "Device" to "Playback device" to make clear what the setting
refers to.
Introduce const expressions to get rid of repeated strings with a risk
of typos.
Make the option to record samples more prominent by providing a pixmap
button that is always shown and that can be used to turn recording on or
off. The corresponding widget which constitutes of the button and a label
is always positioned at the bottom left of the sample clip.

Technical details
------------------
The recording widget is built in the private method `buildRecordWidget`.
The method `adjustRecordWidget` is used to move the recording widget to
the correct position relative to the sample view. It is called after
construction and whenever the sample clip is resized (see `resizeEvent`).

Add the method `SampleClip::getRecordModel` so that the pixmap button can
be configured to act on it.
Only show the recording widget in the sample clip if the audio engine has
a device configured that can capture audio. For simplicity of the code,
i.e. no nullptr checks, the widget is always created but only shown if
capture capabilities are available.

Rename the context menu entry "Set/clear record" to "Toggle record" and
only enable it if capture is possible.

In `SampleClipView` the test for the availability of a capture device is
abstracted behind the helper method `recordingCapabilitiesAvailable`.

Technical details
------------------
Add the method `captureDeviceAvailable` to `AudioEngine` because clients
should not be concerned with driver details. Drivers should mostly be
used by the audio engine and therefore hidden to clients. Add a private
`const` version of the method `audioDev` so that `captureDeviceAvailable`
can be implemented in a `const` correct way.

Use `captureDeviceAvailable` in the constructor of `SongEditorWindow`.
Remove the recording button that was added to the sample clip view with
commit 48c4dce.

This commit simply reverts the aforementioned one.
Gootector and others added 30 commits October 27, 2024 11:10
* Fix: unnecessary space in Update EqControlsDialog.cpp

Fix: unnecessary space in Update EqControlsDialog.cpp

Greetings,
Gootector

* Style fix from Ross

---------

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>
* Update SlicerT UI

* Style review

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>

* Style fixes

---------

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>
Remove all content margins and spacing between child widgets for each mixer channel strip.
This problem seem to arise due to casting _n->framesLeft() and _n->offset() from an unsigned type (size_t) to a signed type (int). The fix is to use size_t as the type for std::max across the board.
* Move common effect processing code to wrapper method

- Introduce `processImpl` and `sleepImpl` methods, and adapt each effect
plugin to use them
- Use double for RMS out sum in Compressor and LOMM
- Run `checkGate` for GranularPitchShifterEffect
- Minor changes to LadspaEffect
- Remove dynamic allocations and VLAs from VstEffect's process method
- Some minor style/formatting fixes

* Fix VstEffect regression

* GranularPitchShifterEffect should not call `checkGate`

* Apply suggestions from code review

Co-authored-by: saker <sakertooth@gmail.com>

* Follow naming convention for local variables

* Add `MAXIMUM_BUFFER_SIZE` and use it in VstEffect

* Revert "GranularPitchShifterEffect should not call `checkGate`"

This reverts commit 67526f0.

* VstEffect: Simplify setting "Don't Run" state

* Rename `sleepImpl` to `processBypassedImpl`

* Use `MAXIMUM_BUFFER_SIZE` in SetupDialog

* Pass `outSum` as out parameter; Fix LadspaEffect mutex

* Move outSum calculations to wrapper method

* Fix Linux build

* Oops

* Apply suggestions from code review

Co-authored-by: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: saker <sakertooth@gmail.com>

---------

Co-authored-by: saker <sakertooth@gmail.com>
Co-authored-by: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com>
* changed font sizes to better values

* rename gui_templates.h to FontHelper.h

* replace hardcoded values with constants

* make knob labels use small font

* code review from michael

* more consolidation

* Fix text problem in Vectorscope

Fix a problem with cutoff text in Vectorscope. During the constructor
call of `LedCheckBox` the method `LedCheckBox::onTextUpdated` is
triggered which sets a fixed size that fits the pixmap and the text.
After instantiating the two instances in `VecControlsDialog` the
constructor then set a minimum size which overrode the fixed size that
was previously set. This then led to text that was cutoff.

---------

Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de>
* Add fast fma functions

* Use fast fma functions

* Add fast pow function

* Use fast pow function

* Fix build

* Remove fastFma

* Avoid UB in fastPow

On GCC with -O1 or -O2 optimizations, this new implementation generates
identical assembly to the old union-based implementation
* fix out-of-bounds crash in AudioFileProcessor

by correctly setting m_from and m_to without them interfering with each other

* fixed flattened wave caused by inaccurate math

see PR for before/after

* simply stop drawing AFP waveform when there's no more data

this fixes the single point at the end of waveforms that sometimes shows up

* fixed seemingly insignificant type confusion (?)

execution seemed fine but my debugger started freaking out,
and if gdb is telling me I got a negative-sized vector,
I'd rather fix this issue than speculate "it's probably fine"

* fixed data offset for AFP waveform vis

the data itself isn't reversed, so we have to account for that
Add proportional scrolling to the song editor, piano roll and automation editor. Proportional scrolling means that if for example a certain measure is on the right side of the song editor then it will take a certain number of mouse wheel moves to get it to the left side of the editor. It is the same number of wheel moves regardless of the zoom level.
Fix the problem with empty windows as described in issue LMMS#7412.

The `refocus` method in `MainWindow` is made public so that it can be called from `Editor::closeEvent`. It has also been refactored for better readability.

---------

Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
Removed code that's has been deactivated using `#if 0`.
Align the rename line edit for tracks.

Make sure that the rename line edit of the `TrackLabelButton` has the
same font size as the widget itself. Because the font size is defined
via style sheets the font size of the line edit has to be set when the
actual renaming starts and not in the constructor. The reason is that
style sheets are set after the constructor has run.

Rename the local variable `txt` to the more speaking name `trackName`.

Ensure that the line edit is moved to the correct place for different
icon sizes by taking the icon size into account. To make this work this
also has to be done in the `rename` method.

## Other changes

Streamline the default style sheet of `TrackLabelButton` by removing
repeated properties that are inherited from the "main" style sheet, i.e.
that are already part of `lmms--gui--TrackLabelButton`.

Interestingly, the `background-color` property had to be repeated for
`lmms--gui--TrackLabelButton:hover`.

---------

Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de>
## Fix rendering of maximized sub windows

### Adjustments in paintEvent
In `SubWindow::paintEvent` don't paint anything if the sub window is
maximized . Otherwise some gradients are visible behind the maximized
child content.

### Adjustments in adjustTitleBar
In `SubWindow::adjustTitleBar` hide the title label and the buttons if the
sub window is maximized. Always show the title and close button if not
maximized. This is needed to reset the state correctly after
maximization.

Remove some calls to `isMaximized` where we already know that the sub
window is not maximized, i.e. where these calls would always return
`false`.

One adjustment would have resulted in a call to `setHidden(false)`. This
was changed to `setVisible(true)` to get rid of the double negation.

The other `false` would have gotten in an or statement and thus could be
removed completely.

### Add method addTitleButton
Add the helper method `SubWindow::addTitleButton` to reduce code
repetition in the constructor.

### Other changes
Remove a dependency on the `MdiArea` when checking if the sub window is
the active one. Query its own window state to find out if it is active.

When calling `setWindowFlags` in the constructor only adjust the existing
flags with the changes that we actually want to do. It was ensured that
all other flags that have been set before still apply with this change.
Put the elements of the `TrackOperationsWidget` into layouts. These are:
* The grip that can be used to move tracks
* The gear icon that opens the operations menu
* The mute button
* The solo button

The grip that can be used to move tracks around is extracted into its own class called `TrackGrip`. This has several advantages:
* It can be put into a layout.
* It can render itself at arbitrary sizes by simply repeating its pattern pixmap.
* It can be used in a much more object-oriented way because it emits signals when it is grabbed and released.
* It is responsible for locally updating its cursor state.

The default cursor of the grip now is an open hand which indicates to the users that it can be grabbed. While being grabbed the cursor now is a closed hand.

## Technical details
The class `TrackOperationsWidget` now holds an instance of `TrackGrip` and provides a getter to retrieve it. This getter is used by `TrackView` to connect to the two new signals `grabbed` and `released`. The method `TrackOperationsWidget::paintEvent` now only paints the background as it does not need to paint the grip anymore.

The `TrackView` now handles the grabbing and release of the grip in `TrackView::onTrackGripGrabbed` and `TrackView::onTrackGripReleased`. Because the events and cursor states are now handled by `TrackGrip` this code could be removed from `TrackView::mousePressEvent`.

There was a comment in `TrackView` which indicated that the `TrackOperationsWidget` had to be updated when the track is moved and released because it would hide some elements during the move. The comment and the corresponding code was removed because the operations widget does not hide its elements during moves (this was already the state before the changes made by this commit).

Adjust the style sheets of the classic and default themes with regards to the `QPushButton` that's used to show the gear menu in the `TrackOperationsWidget`. The `>` has been removed because the `QPushButton` is not a direct decendent of the `TrackOperationsWidget` anymore.

### Wrapping of `PixmapButton` in `QWidget`
The PixmapButtons that are used in `TrackOperationsWidget` current have to be wrapped into a `QWidget`. This is necessary due to some strange effect where the PixmapButtons are resized to a size that's larger than their minimum/fixed size when the method `show` is called in `TrackContainerView::realignTracks`. Specifically, with the default theme the buttons are resized from their minimum size of (16, 14) to (26, 26). This then makes them behave not as expected in layouts.

The resizing is not done for QWidgets. Therefore we wrap the PixmapButton in a QWidget which is set to a fixed size that will be able to show the active and inactive pixmap. We can then use the QWidget in layouts without any disturbances.

The resizing only seems to affect the track view hierarchy and is triggered by Qt's internal mechanisms. For example the buttons in the mixer view do not seem to be affected.

If you want to debug this simply override "PixmapButton::resizeEvent" and trigger a break point in there, e.g. whenever the new size is not (16, 14).

### More layout-friendly PixmapButton

Make the `PixmapButton` more friendly for layouts by implementing `minimumSizeHint`. It returns a size that accommodate to show the active and the inactive pixmap.

Also make `sizeHint` return the minimum size hint. The previous implementation would have made layouts jump when the pixmap is toggled with pixmaps of different sizes.
Remove the member `PluginView::m_isResizable` and it's associated method `setResizable`. Turn `isResizable` into a virtual method.

The reasoning is that whether or not an effect can be resized depends on its implementation. Therefore does not make sense to have a method like `setResizable`. If the underlying implementation does not support resizing then it would not make sense to call `setResizable(true)`. So `isResizable` now describes the underlying ability of a plugin to resize. It's then up to the clients of that method to decide how to treat the result of `isResizable`, i.e. if they want to make use of the ability to resize or not.
* Optimize dBFS <-> amplitude functions
* Remove QTextCodec

QTextCodec was removed from Qt6 and is only available through the
Qt5Compat module.

QTextCodec was only used by the HydrogenImport plugin when importing old
Hydrogen files that were saved using TinyXML before it supported UTF-8.
HydrogenImport would use QTextCodec to try to get the current encoding
from the locale, and then use that as a best guess for interpreting the
XML data in the unspecified encoding it was saved in. None of this was
ever reliable, since the encoding of the computer that saved the
Hydrogen file might not be the same as the computer running LMMS and
importing that file.

There is no good solution here, so I decided to simply assume the old
Hydrogen files are UTF-8 encoded. The worst that can happen is someone's
ancient Hydrogen files containing non-ASCII text of some random encoding
becomes mojibake'd after importing into LMMS, which is something that
already could have happened.

* Clean up a little
…#7549)

* Inline TimeSig functions

* Inline TimePos functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.