Coder Social home page Coder Social logo

soft_matrix's People

Contributors

gwbasic avatar

Watchers

 avatar

soft_matrix's Issues

Experiment with integer-based processing

One thing to try is using 24-bit waves instead of floating point.

  1. See if fft can run with 32-bit or 64-bit ints
  2. Try shifting 24-bit audio up to 32-bit (or higher) to avoid rounding errors

Music fades in

To reproduce:

  1. Upmix a steady sine wave
  2. Observe that the result "fades in"

I suspect this has to do with the slight amount of silence used to buffer the beginning.

Source sine wav:
image

Upmixed. Observe fade-in at the beginning and end:
image

Switch transforms from RefCell to Option

In order to avoid unneeded copying of transform vectors:

  • They are stored as RefCell and swapped
  • 0-length vectors are used when the transform isn't needed.

Instead, use an Option and None when no transform is needed

Phase shift rear channels

One rear channel needs to be +(0.5 pi), the other needs to be -(0.5 pi).

According to https://en.wikipedia.org/wiki/QS_Regular_Matrix:

  • The left-back needs to be -(0.5 pi). (It's shifted forward on encoding and backwards on playback)
  • The right-back needs to be +(0.5 pi) (It's shifted backwards on encoding and forward on playback)

Note that Dolby Surround tends to have the same phase shift for the back:

Make samples per transform configurable

Currently, there is one Fourier transform per sample. See if there is a way to have a single Fourier transform shared among a few samples.

Even if the quality is poor, this might be a good way to preview results quickly.

Support SQ

For SQ: https://en.wikipedia.org/wiki/Stereo_Quadraphonic
https://en.wikipedia.org/wiki/Matrix_decoder#SQ_matrix,_%22Stereo_Quadraphonic%22,_CBS_SQ_(4:2:4)

Rear left: Right is (3/4)pi ahead
Rear center: 135 degrees difference between channels, right is 135 degrees forward relative to left
Rear right: Right is (1/4)pi behind

https://www.desmos.com/calculator/zimzev6yla

l: left back in left total
e: right back in right total
k: left back in right total
r: right back in right total

Bottom functions:

Rear center in left total
Rear center in right total

Amplitude levels are wrong in SQ

Support was added for SQ in #70

One issue is that amplitude levels are wrong when a tone is panned front-to-back, or along the back channels.

In the following screenshot, all tone amplitudes should be equal:

#70

Ignore phase in LFE

Branch IgnorePhaseInLFE has an attempt to ignore phase in the LFE. It's very staticy when normalized.

Remove "loud" matrixes and instead make "loud" an option

In general, when mixing in stereo, items in the center channel need to be at amplitude 0.707 in order to be as loud as items isolated in a speaker at amplitude 1.0.

During upmixing, this creates a complication: If a tone plays at amplitude 1.0 in both speakers, it will be directed to the center speaker at amplitude 1.414213562373095. This will create clipping.

There are two options to handle this:

  • Lower all amplitudes by .707. This what most matrixes do
  • Allow clipping. This is what the loud matrixes do

In this ticket:

  • Get rid of the "loud" matrixes
  • Each matrix should have, as a property, an "adjustment" value. This will normally be .707. During writing, everything will be adjusted by this value
  • The loud option should skip this value, although there should be a warning that clipping may occur

Support horseshoe surround and super-stereo

Horseshoe surround:

  • Ignore phase
  • Right and leftmost sounds are in the rear channels
  • Mid-panned sounds are in the front

Super-stereo:

  • Halfway between horseshoe and surround
  • Extreme left and extreme right are panned halfway to the back
  • Completely out of phase is panned halfway to the back

Move logging to the main loop

Logging currently happens after writing a sample. This creates a large delay between starting and logging.

Instead, logging's percentage should be based on the number of forward and backward transforms performed:

  • At startup, calculate the total number of transforms to complete (both forwards and backwards)
  • Keep a count of the number of transforms performed (both forwards and backwards)

The check for logging should happen whenever the counts of transforms are incremented.

Make reading stream based

Make reading stream based:

  • Read from an iter
  • Automatically pad the buffers for the fourier transforms
  • Automatically pad (or alternate heuristic) the queue of calculated right/lefts

This will be useful to allow reading the wav from stdin; which will allow using sox or similar to read formats other than wav

Support 5.1

Output currently is currently 4 channels; output should be 5.1

To start, introduce an options processor:

  • Options struct
  • Static method to parse options from arguments

Refactor to use separate files for the three phases of upmixing

There are three phases in upmixing:

  1. Read from the wave and perform a forwards transform
  2. Average / smooth the panning
  3. Perform actual panning, a backwards transform, and write to the wave file

Each phase should be a separate file. (Keeping them all in upmixer.rs is unwieldy.) Each file should have a struct to maintain its state, and use closures as dependency injection to send along the next phase in processing.

Files are truncated to about an hour

Upmixing a file that's 2:05:56 (Just under 2 hours, 6 minutes) long, was truncated to 58:18. (Fifty-eight minutes, eighteen seconds.)

Not sure why

Edit: The root cause is that wave_stream doesn't support files longer than RIFF's 32-bit size values: GWBasic/wave_stream#30

To fix this: I'm going to implement some file splitting logic. Wav files longer than 4GB have inconsistent support, but Sox can concatinate into other formats that support long files.

Currently shifts pitch

When hardcoding the front-to-back to be the front, the pitch is always shifted up.

In this ticket, get a "no-op" with silent rear channels and no pitch shift.

See if there is a faster way to copy vectors

In the final phase of upmixing, when sound is steered, the vectors for the transforms are copied so that there are transforms for the front and back.

The copy occurs via a .tovec();

See if there is a faster way to copy these vectors.

(An early lesson is that copying vectors to maintain memory integrity had a lot of overhead, and using RefCells that allowed swapping, and empty vectors where the transforms are ignored, is much faster.)

Document all options

Typing "soft_matrix" with no options should give an informative set of instructions

Only end the thread if all samples are written

If the averaging phase takes too long, and there's no more input, threads will exit. This could leave a single thread performing all of the backwards transforms and writing.

To fix this:

  1. Keep a counter of the number of samples written
  2. Only end the thread if all samples are written
  3. Instead of ending the thread, lock on the averaging mutex. This will block the thread until averaging completes

Rename rm to qs

The article on QS states that it's incorrectly refferred to as RM: https://en.wikipedia.org/wiki/QS_Regular_Matrix

RM (Regular Matrix) was often used a synonym for the 'Sansui QS', 'Toshiba QM' and 'Nippon Columbia QX' matrix systems that were previously launched before the advent of the RM specification in 1973. Although none of the three previous matrices were compatible with the new RM specification, and with Toshiba and Nippon Columbia withdrawing their 'further RM incompatible' matrix systems from the market, Sansui's QS system was unofficially labelled by some record labels as RM, until the situation was clarified to those responsible for the mislabeling

Open-source wave_stream

At this point, I believe I've used wave_stream enough to open-source it.

It's getting awkward using a private reference to wave_stream.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.