musikinformatik / SuperDirt

Tidal Audio Engine
GNU General Public License v2.0
519 stars 75 forks source link

pan0 in -1 to 1 range #222

Open yaxu opened 3 years ago

yaxu commented 3 years ago

(We've gone through this before elsewhere including in #36 but would be good to tackle it with #190 in mind)

A couple of problems in one

To solve just the first problem, we could add pan0 for the 0 .. 1 range.

To solve both problems, in addition in stereo mode 0.25 is left, 0.75 is right. 0.5, 1 and 0 would all be centre. 0.5 .. 0.75 would then be the same as 1 .. 0.75.

In multichannel mode 0.25 and 0.75 would also be left and right, but 0.5 would be front and 0 and 1 would be rear.

(I might be mixing up left/right and front/rear, I'm not too bothered about where they go :) )

(not sure what to call a -1 .. 1 signal. I thought it was a 'bipolar' signal but looking it up that seems to be one in a binary state)

I've already made sine0, tri0 etc in tidal to support the -1 .. 1 range.

telephon commented 3 years ago

some questions:

(not sure what to call a -1 .. 1 signal. I thought it was a 'bipolar' signal but looking it up that seems to be one in a binary state)

in sclang, we have unipolar 0...1 and bipolar -1...1.

I've already made sine0, tri0 etc in tidal to support the -1 .. 1 range.

if pan is unipolar and pan0 bipolar, then shouldn't sine and sine0 be analogous? One possibility is to add 2 to the names to signify bipolarity, so pan2, sine2, tri2.

telephon commented 3 years ago

Just to be sure, here is a plot of the standard pan for 8 channels:

(
{ 
    var sig = DC.ar(1);
    var pan = Line.ar(-1, 1, 1/100);
    DirtSplayAz.ar(8, sig, 1, pan, orientation: 0);
}.plot(1/100)
)
Screenshot 2021-01-24 at 15 18 06
yaxu commented 3 years ago

Ah sorry for mixing up front and rear, to tell the truth I just switch cables around until things sound right. :)

In earlier versions of tidal sine was bipolar and sine1 was the range 0..1. Eventually I standardised sine and the other signals as unipolar to match the effect range in dirt (including pan), and there was no bipolar version.

I thought the 0 suffix would make sense as that's the what the signal is centred on, which means you can add/multiply them together. That there's a range of 2 somehow seemed less important? But then the unipolar signal should be sine0.5, which seems silly. I guess you suggest 2 not because there's a range of 2 in particular, but because it goes in two directions relative to 0..

I still think it makes sense for most effects to be unipolar. But then it's nice to be able to multiply signals together to get a more complex waveform before scaling to the 0 .. 1 range. Unfortunately tidal's range operator assumes a unipolar input.

Maybe this needs solving with types. Then sine can be of type Pattern Unipolar and sine2 of type Pattern Bipolar and both can be of typeclass Signal, membership of which requires the conversion function needed by the range function. Plus there can be toUni and toBi functions for quickly converting between them.

telephon commented 3 years ago

That there's a range of 2 somehow seemed less important?

no, sorry, that's not what I meant. In supercollider, the bipolar versions have a 2 on the end, like clip2. As long as all is consistent it's file (0 is intuitive as well).

yaxu commented 3 years ago

Ok I think I prefer 2 and good to keep consistent with supercollider as well.

I guess there's no specific function for conversion in supercollider, as (sig+1)/2 is so easy?

yaxu commented 3 years ago

Oh and yes tidal could just always send pan0 (or rather, pan2), doing any conversion. pan could then be deprecated in superdirt, but stay be there for backward compatibility.