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

backport from #1055 and #1012 #1101

Merged
merged 5 commits into from
Jan 16, 2025
Merged

backport from #1055 and #1012 #1101

merged 5 commits into from
Jan 16, 2025

Conversation

sss-create
Copy link
Collaborator

@sss-create sss-create commented Jan 10, 2025

backported from: #1055

As the title says + testing :)
I just wonder what happens when shifting time:

tidal> s "bd sn bd bd bd cp sn" # nudge ( 1002 <~ rand)
  (0>⅐)|nudge: 0.26717657037079334f, s: "bd"
  (⅐>²₇)|nudge: 5.507626384496689e-2f, s: "sn"
  (²₇>³₇)|nudge: 8.829252980649471e-2f, s: "bd"
  (³₇>⁴₇)|nudge: 0.12956790439784527f, s: "bd"
  (⁴₇>⁵₇)|nudge: 0.4096888657659292f, s: "bd"
  (⁵₇>⁶₇)|nudge: 0.1880505084991455f, s: "cp"
  (⁶₇>1)|nudge: 0.9954968336969614f, s: "sn"

tidal> s "bd sn bd bd bd cp sn" # nudge ( 1002 <~ normal)
  (0>⅐)|nudge: 1.0577018423203732f, s: "bd"
  (⅐>²₇)|nudge: 1.3265466381271827f, s: "sn"
  (²₇>³₇)|nudge: 1.2562830059776906f, s: "bd"
  (³₇>⁴₇)|nudge: 1.1939579886268699f, s: "bd"
  (⁴₇>⁵₇)|nudge: 0.9585745094129575f, s: "bd"
  (⁵₇>⁶₇)|nudge: 1.1275300958307755f, s: "cp"
  (⁶₇>1)|nudge: 0.5326128959276948f, s: "sn"

Is it correct that values are not clamped between 0 and 1 anymore even with rand -- or are these values normalized internally then?

@sss-create sss-create changed the title backported normal function to generate bell curve random values backport from #1055 Jan 10, 2025
@sss-create sss-create changed the title backport from #1055 backport from #1055 and #1012 Jan 10, 2025
@yaxu
Copy link
Member

yaxu commented Jan 13, 2025

Tagging @patrickt

@yaxu
Copy link
Member

yaxu commented Jan 13, 2025

Agreed that it should be scaled to the 0..1 range.

Saying that, in the 2.0 branch I did start organising things so all the signals had a 2 version that was bipolar i.e. from -1 to 1.. We can backport that in a separate PR though.

-- | Sawtooth waveform
saw :: (Fractional a, Real a) => Signal a
saw = waveform $ \t -> mod' (fromRational t) 1
saw2 :: (Fractional a, Real a) => Signal a
saw2 = toBipolar saw

Also looking at the normal function I also see that rot 1 is used to try to get a different random stream. I think that should be rotL 1.

@sss-create
Copy link
Collaborator Author

I'll further investigate the scaling issues and take a look at the bipolar implementation in the tidal 2 branch. Looks interesting!

@sss-create
Copy link
Collaborator Author

It looks like the bipolar version is already in the dev branch:

-- | @saw@ - unipolar ascending sawtooth wave. A pattern of continuous values
-- following a sawtooth with frequency of one cycle, and amplitude from
-- 0 to 1.
saw :: (Fractional a, Real a) => Pattern a
saw = sig $ \t -> mod' (fromRational t) 1
-- | @saw2@ - bipolar ascending sawtooth wave. A pattern of continuous values
-- following a sawtooth with frequency of one cycle, and amplitude from
-- -1 to 1.
saw2 :: (Fractional a, Real a) => Pattern a
saw2 = sig $ \t -> mod' (fromRational t) 1 * 2 - 1

@yaxu
Copy link
Member

yaxu commented Jan 15, 2025

It looks like the bipolar version is already in the dev branch:

Oops, sorry for the distraction!

@sss-create
Copy link
Collaborator Author

These now look way more like normal distributed values:

tidal> s "bd sn bd bd bd cp sn" # nudge ( 1002 <~ normal)
  (0>⅐)|nudge: 0.4614305436669617f, s: "bd"
  (⅐>²₇)|nudge: 0.1837912906828634f, s: "sn"
  (²₇>³₇)|nudge: 0.21515425648364675f, s: "bd"
  (³₇>⁴₇)|nudge: 0.17697178051416398f, s: "bd"
  (⁴₇>⁵₇)|nudge: 0.470017897933857f, s: "bd"
  (⁵₇>⁶₇)|nudge: 0.3055551880905872f, s: "cp"
  (⁶₇>1)|nudge: 0.5f, s: "sn"

tidal> s "bd sn bd*7cp sn" # nudge ( 1002 <~ normal)
  (0>⅕)|nudge: 0.2527900002825703f, s: "bd"
  (⅕>⅖)|nudge: 0.5f, s: "sn"
  (⅖>³₇)|nudge: 0.5f, s: "bd"
  (³₇>16/35)|nudge: 0.5f, s: "bd"
  (16/35>17/35)|nudge: 0.5f, s: "bd"
  (17/35>18/35)|nudge: 0.17697178051416398f, s: "bd"
  (18/35>19/35)|nudge: 0.4679114687283475f, s: "bd"
  (19/35>⁴₇)|nudge: 0.47189795787381655f, s: "bd"
  (⁴₇>⅗)|nudge: 0.5f, s: "bd"
  (⅗>⅘)|nudge: 0.5f, s: "cp"
  (⅘>1)|nudge: 0.5f, s: "sn"

Do you think this can be merged now or do you have a testing method in mind for this? I calculated the mean outside Tidal and got values very close to 0.5f.

@yaxu
Copy link
Member

yaxu commented Jan 16, 2025

Looks good! I'm not sure exactly what's going on, but it's probably a good idea to change rotL 1 to more like rotL 1000 to sample from a separate part of the random stream..

@yaxu
Copy link
Member

yaxu commented Jan 16, 2025

You should have access now to merge when ready

@sss-create sss-create merged commit bec7416 into tidalcycles:dev Jan 16, 2025
19 of 23 checks passed
@sss-create sss-create deleted the normal branch January 18, 2025 18:53
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.

2 participants