Commit Graph

3157 Commits (7813712df3d0782b7bc38e71d2701961eccf9337)

Author SHA1 Message Date
Christopher Snowhill 7813712df3 [Audio Threads] Correctly set real time priority
I'm not sure about macOS Ventura, but stable releases of macOS, at
least on Intel, require that threads joining Audio Interval
workgroups already be set to run as real-time before joining. Not
doing this results in an uncaught exception and a crash.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 18:15:44 -07:00
Christopher Snowhill 91898e9e77 [Audio Threads] Change workgroup system again
Now it allocates audio workgroups per thread, using work slices like the
Apple documentation describes for asynchronous threads.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 01:38:30 -07:00
Christopher Snowhill fef8821cf6 [Visualizer] Add extra condition to visible check
Add an extra condition to the visibility check, which is similar to the
previous version of this check, which now guards against the window it
is hosted in not being visible.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 00:43:23 -07:00
Christopher Snowhill 6179b304d0 [Audio Threads] Join output device workgroup
On Big Sur or newer, it is possible to join the audio threads to the
same OS workgroup as the audio output device, improving response.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 00:27:55 -07:00
Christopher Snowhill cdcbabd72f [Visualizer] Accidentally left in debug test code
This was changed to verify the legacy code still works.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-08 21:56:47 -07:00
Christopher Snowhill 1728debe94 [Visualizer] Bring back CoreGraphics visualizer
For legacy systems that do not support Metal. The Metal SceneKit view
does work on even 10.13.6, if a Metal GPU is present in the system.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-08 21:32:52 -07:00
Christopher Snowhill f2b015c149 Merge branch 'xcode14' 2022-06-07 19:06:48 -07:00
Christopher Snowhill 6022526ad4 [Visualization] Improve hidden window detection
The NSView should detect if it's a visible control in a window

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-07 19:01:47 -07:00
Christopher Snowhill fc7a8dbcb7 [Vorbis Plugin] Fix compilation on case sensitive
Fix compilation when source code is checked out on a case sensitive file
system.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-07 18:58:45 -07:00
Christopher Snowhill f11ef2d887 [Playlist Controller] Fix ambiguity with Xcode 14
This NSArray member call is ambiguous, but Xcode <14 allowed it.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-07 18:57:19 -07:00
Christopher Snowhill 00ea4562dc Update project files for Xcode 14 recommendations
Update all project files with new upgrade version number, and add the
dead code stripping option. Don't touch MASShortcut because it's not my
project.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-07 18:56:11 -07:00
Christopher Snowhill dc103ac546 [Visualizer] Disable processing when vis is hidden
When visualizer windows are created, but not actually visible, stop the
update timer, to save processing, especially if the vis is enabled in
one or the other main/mini windows.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-06 08:19:42 -07:00
Christopher Snowhill c208f60da4 [HRIR Convolver] Rewrite to use PFFFT float
Replace overlap-add vDSP/Accelerate implementation with a faster PFFFT
overlap-save implementation, using fewer FFT steps as well.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-06 08:18:33 -07:00
Christopher Snowhill 18af8a06df [Output] [Downmixer] Optimize a bit
Rewrite some of the output and a lot of the downmixer to use Accelerate
framework instead of dumb for loops.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-06 08:16:27 -07:00
Christopher Snowhill 0ba766023e Playlist/Time: Simplify font initialization
Apparently this simpler API already existed on a minimum of 10.11 for
creating a system font with monospaced digits.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-03 16:46:37 -07:00
Christopher Snowhill eaa73bc52f [Threading] Queue expensive actions outside audio
Use delayed dispatching on expensive operations which occur every time
the "heard" track end happens, and when audio metadata is changed by a
stream, so that they are inserted into the main thread queue after the
invoking callback returns control execution back to the audio thread.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 23:59:42 -07:00
Christopher Snowhill 4a0b337936 [Resampler] Change pffft_double project import
Change import from folder reference to group, like I originally
intended.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 22:31:49 -07:00
Christopher Snowhill 05f17ea950 [Menu] Add Stop after Selection to context menu
Since the existing code already supports setting any arbitrary track as
a stopping point, add a menu interface to toggle Stop After for any
track in the playlist. Stop After will be removed from the given track
after it has been played. Stop After will not be remembered on disk.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 22:23:02 -07:00
Christopher Snowhill aabd9431f1 [Visualization] Gate registered observers
Gate registering observers behind a check variable in the object state,
which will be zero initialized by the Objective-C runtime, and will
prevent the class from erroneously unregistering observers without them
being registered in the first place. Apparently, services cannot be
unregistered if they were never registered first, or else an exception
will be thrown upon attempting to unregister them. This fixes a crash on
startup in the now several times running failure to work properly on
legacy Macs without Metal graphics, now that the new visualization
system has been implemented.

It's probably not worth bringing back the previous Core Graphics based
visualizer method anyway, as on those same legacy machines, it was
causing out of control CPU usage by WindowServer. At least on modern
Macs, any amount of 60fps UI updating will cause WindowServer to use
about 45% of a core, regardless of how many apps are drawing that much
at once.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 21:38:29 -07:00
Christopher Snowhill 94057cf467 Updated VGMStream to r1745-22-gf696beb0
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 18:26:34 -07:00
Christopher Snowhill bea896cca5 [Resampler] Switch r8brain back to PFFFT double
Apparently, PFFFT double is much faster than vDSP, and I didn't even
notice. Thanks to Aleksey Vaneev for testing this properly.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 18:24:37 -07:00
Christopher Snowhill 50342891af [Convolver] Normalize HRTF impulse when resampling
When resampling the impulse according to the playback rate, it becomes
necessary to normalize the resulting impulse by the inverse of the
sample ratio, as resampling adds more or less loudness by virtue of
interpolating samples.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 01:39:12 -07:00
Christopher Snowhill 7e0b7f2008 [Resampler] Update r8brain with proper commit
This will be proper at least unless I get this commit merged upstream.
Squashed the changes to a single commit, and removed extraneous
whitespace that crept into the code.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 01:37:11 -07:00
Christopher Snowhill 8c2df13f3b [Visualization] Disable visualization if no Metal
If the system has no working Metal devices, disable the visualization.

The legacy visualization was also too slow for said systems to handle
reasonably anyway, so I guess it's safe to say that they shouldn't have
to handle any visualizers at all. At least have working audio playback,
of course, since that is the primary function of the application. Too
bad that the OpenGL renderers don't work on my scene, it would be nice
to have a fallback there. GL 4.1 crashes on an M1, and both GL 4.1 and
3.2 crash with SIGFPE division by zero error on Intel Macs without Metal
devices. Meh.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-30 00:15:49 -07:00
Christopher Snowhill 539a8c79eb [Visualization] Remove default Metal device option
Remove the default Metal device option, as it can return nil on systems
where it won't be expected to work.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-28 19:32:26 -07:00
Christopher Snowhill ec18d0b260 [Visualization] Fix crash with frequency mode
The frequency mode, apparently the default, doesn't like that the code
was setting the width of the spectrum data to 11 instead of the default
1000. This was causing it to overwrite freed memory when the spectrum
started processing audio.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-28 18:31:09 -07:00
Christopher Snowhill 6b381f3d08 [Visualization] Remove OpenGL fallback
The OpenGL fallback was causing division by zero errors on Intel Macs
running macOS High Sierra.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-28 18:23:15 -07:00
Christopher Snowhill 5e5b2e4071 [Visualization] Add micro bias to cylinder scale
Apparently, old macOS wants to divide something by the scale size, so
setting it to zero causes division by zero errors? Let's set it to a
really small number instead.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-27 04:33:07 -07:00
Christopher Snowhill 0cc7e61434 [Resampler] Remove another bad block of code
Oops, I missed some code when fixing it up.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-27 04:09:51 -07:00
Christopher Snowhill f89f1dad5a Change comment to be more correct
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-27 04:06:17 -07:00
Christopher Snowhill 527976197a [Resampler] Oops, made an error with multiply
The function I added only works for non-interleaved real/imaginary pairs
and not the interleaved setup that r8brain expects. Fix that by removing
the multiply implementation and using the original one.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-27 04:01:49 -07:00
Christopher Snowhill 381e52178c [Resampler] Change FFT to use Accelerate framework
The used fork of r8brain now uses the Accelerate vDSP FFT functions for
resampling, which should provide a slight speedup, or significant for
large sample ratios.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-27 03:40:14 -07:00
Christopher Snowhill 4d25b41462 GME Plugin: Silence a type truncation warning
Adding a cast here silences a warning from passing a long to a function
accepting an int. It doesn't really matter here anyway, as the long in
question is hard coded to initialize to a fixed sample rate. Even when
sample rate configuration is eventually added, this will still be hard
capped to well within the range of 32-bit integers.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-24 01:11:07 -07:00
Christopher Snowhill 872816f056 VGM Decoder: Change logic of dictionary creation
Metadata logic code should be using this dictionaryWithDictionary method
so that the resulting dictionary is actually immutable, like it claims
to be, rather than simply casting it. Safety coding, all that jazz. Not
really a major issue, just feels right.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-24 01:09:39 -07:00
Christopher Snowhill 8cf37cadf3 Unicode metadata: Change most logic to use guesser
Most file formats the player supports may or may not have UTF-8 safe
strings in their metadata. This should not be assumed to be UTF-8, and
when it is assumed, it results in nil NSString objects, which results in
inline initializers crashing due to uncaught exceptions.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-24 01:07:55 -07:00
Christopher Snowhill f7dc6beda1 Plugin utilities: Moved encoding guesser to header
Moved the string encoding guesser/converter to the Plugin.h header, so
it may be accessible from any plugin. I may make it a global member of
something eventually, but a static inline for such a simple function
should be fine for now.

This function facilitates converting arbitrary 8 bit encoded strings to
Unicode NSString objects. It should be used anywhere that UTF-8 is
expected, but not necessarily guaranteed, and where other 8-bit
encodings may also be supplied by a user's files.

Not using this setup for string inputs has already led to failed UTF-8
decoding resulting in nil NSStrings being passed to the inline array or
dictionary initializers, which results in crashes due to uncaught
exceptions.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-24 01:05:43 -07:00
Christopher Snowhill 4b2cf22800 [Visualization] Use OpenGL on legacy systems
On legacy OSes, and legacy GPUs, it should use OpenGL and not Metal,
otherwise there could be horrible performance, or even crashes.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-23 17:21:13 -07:00
Christopher Snowhill c59d4d0215 [Visualization] Tear down window vis when not open
When the visualization window is not open, it should not continue to run
the scene until the app is quit. Apparently, the windowed mode is really
slow on old Intel machines, too. Full screening it is enough to bodge
the entire system session until the machine is remotely rebooted.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 18:39:32 -07:00
Christopher Snowhill 84eadd1f33 [Visualization] Use forced 3D mode in window
Windowed style should always use the perspective camera mode.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 17:45:51 -07:00
Christopher Snowhill 438634d6df [Visualization]: Change peaks to float on top
Change the peak sphere positions so they float on top of the bottom or
the bars, instead of clipping into them.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 17:25:21 -07:00
Christopher Snowhill f4712ad219 [Visualization]: Add Spectrum window
Add a dedicated spectrum visualization window, and add the necessary
hooks to start its event timer if playback is already running when it is
first opened.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 17:24:35 -07:00
Christopher Snowhill e2d7ebdec5 [Visualization] Enable anti-aliasing
Enable 8x multisampled anti-aliasing, to improve the appearance of the
spectrum on non-Retina/HiDPI displays. It can't really hurt on HiDPI,
either. Hopefully this won't cause it to use a whole load of GPU
resources, more than is reasonable.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 16:32:57 -07:00
Christopher Snowhill 79ac1e0dd6 [Visualization] Adjust Spectrum scene parameters
Disable color fringing and motion blurring, which were causing artifacts
with the transparent background.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 16:31:34 -07:00
Christopher Snowhill b99bc67bac
Merge pull request #256 from losnoco/nevack/spectrum-camera-mode-angles
[Visualizer] Adjust 2d projection camera angles.
2022-05-22 16:28:18 -07:00
Dzmitry Neviadomski a58b11dc90 [Visualizer] Adjust 2d projection camera angles. 2022-05-23 02:12:25 +03:00
Christopher Snowhill 4f1ea02359 README: Add directions for Git hooks path
Since we use a non-default path in the repository to store shared hooks,
it needs to be configured on a freshly cloned repository before it can
be usable.

Yeah, I forgot to follow my own directions before working on the project
for quite some time. The error crept in at the following commit:

2aa3ddd545 - Icon replacement, and team ID

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 16:12:12 -07:00
Christopher Snowhill 25906d1b2b Project file: Remove team ID that leaked in
I accidentally forgot to enable my hooks after cloning on a new macOS
installation.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 16:10:51 -07:00
Christopher Snowhill 4035ca861f Spectrum Visualizer: Add customization options
Add options to the Appearance preferences page to allow changing the
spectrum's projection between a 2D-like one and 3D perspective, and add
options to change the bar and peak dot colors.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 15:26:27 -07:00
Christopher Snowhill fce0e129a5 Spectrum Visualization: Replaced spectrum view
Introduced a brand new spectrum view based on SceneKit, with a scene
created by @kddlb and then altered by me to add the peak spheres. This
new scene should be lighter on display resources, even though it's fully
3D instead of a vector 2D scene done in Cocoa drawing primitives.

Co-authored-by: Kevin Lopez Brante <kevin@kddlb.cl>
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 00:03:52 -07:00
Christopher Snowhill bf54c45242 Info.plist: Updated with new file types
Updated with new file types added by VGMStream.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-02 15:00:39 -07:00