Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit a1876c1

Browse files
authored
Merge pull request #1148 from tidalcycles/signal-onset
[breaking change] sample signals at query onsets instead of midpoint
2 parents 599ba1d + 397f61d commit a1876c1

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/Sound/Tidal/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sig f = pattern q
4040
where
4141
q (State (Arc s e) _)
4242
| s > e = []
43-
| otherwise = [Event (Context []) Nothing (Arc s e) (f (s + ((e - s) / 2)))]
43+
| otherwise = [Event (Context []) Nothing (Arc s e) (f s)]
4444

4545
-- | @sine@ - unipolar sinewave. A pattern of continuous values following a
4646
-- sinewave with frequency of one cycle, and amplitude from 0 to 1.

test/Sound/Tidal/CoreTest.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,21 +296,21 @@ run =
296296
map value (queryArc ((+ 1) <$> saw) (Arc 0.5 0.5)) `shouldBe` [1.5 :: Float]
297297
it "works on the left of <*>" $
298298
queryArc ((+) <$> saw <*> pure 3) (Arc 0 1)
299-
`shouldBe` [Event (Context []) Nothing (Arc 0 1) 3.5 :: Event Double]
299+
`shouldBe` [Event (Context []) Nothing (Arc 0 1) 3 :: Event Double]
300300
it "works on the right of <*>" $
301301
queryArc (fast 4 (pure (+ 3)) <*> saw) (Arc 0 1)
302-
`shouldBe` [ Event (Context []) Nothing (Arc 0 0.25) 3.5 :: Event Double,
303-
Event (Context []) Nothing (Arc 0.25 0.5) 3.5,
304-
Event (Context []) Nothing (Arc 0.5 0.75) 3.5,
305-
Event (Context []) Nothing (Arc 0.75 1) 3.5
302+
`shouldBe` [ Event (Context []) Nothing (Arc 0 0.25) 3 :: Event Double,
303+
Event (Context []) Nothing (Arc 0.25 0.5) 3,
304+
Event (Context []) Nothing (Arc 0.5 0.75) 3,
305+
Event (Context []) Nothing (Arc 0.75 1) 3
306306
]
307307
it "can be reversed" $ do
308308
it "works with whole cycles" $
309309
queryArc (rev saw) (Arc 0 1)
310-
`shouldBe` [Event (Context []) Nothing (Arc 0 1) 0.5 :: Event Double]
310+
`shouldBe` [Event (Context []) Nothing (Arc 0 1) 0 :: Event Double]
311311
it "works with half cycles" $
312-
queryArc (rev saw) (Arc 0 0.5)
313-
`shouldBe` [Event (Context []) Nothing (Arc 0 0.5) 0.75 :: Event Double]
312+
queryArc (rev saw) (Arc 0.5 1)
313+
`shouldBe` [Event (Context []) Nothing (Arc 0.5 1) 0 :: Event Double]
314314
it "works with inset points" $
315315
queryArc (rev saw) (Arc 0.25 0.25)
316316
`shouldBe` [Event (Context []) Nothing (Arc 0.25 0.25) 0.75 :: Event Double]
@@ -320,12 +320,12 @@ run =
320320
comparePD
321321
(Arc 0 1)
322322
(struct "t*8" (tri :: Pattern Double))
323-
"0.125 0.375 0.625 0.875 0.875 0.625 0.375 0.125"
323+
"0 0.25 0.5 0.75 1 0.75 0.5 0.25"
324324
it "can be added to" $
325325
comparePD
326326
(Arc 0 1)
327327
(struct "t*8" $ (tri :: Pattern Double) + 1)
328-
"1.125 1.375 1.625 1.875 1.875 1.625 1.375 1.125"
328+
"1 1.25 1.5 1.75 2 1.75 1.5 1.25"
329329
describe "every" $
330330
it "`every n id` doesn't change the pattern's structure" $ do
331331
comparePD

test/Sound/Tidal/PatternTest.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ run =
216216
]
217217
it "preserves cycle number of inner patterns" $ do
218218
(map value $ queryArc (squeezeJoin (pure $ struct "1" $ (sig $ id))) (Arc 3 4))
219-
`shouldBe` [3.5]
219+
`shouldBe` [3]
220220

221221
describe ">>=" $ do
222222
it "can apply functions to patterns" $ do
@@ -530,7 +530,7 @@ run =
530530
it "filter above given threshold" $ do
531531
let fil = stripContext $ filterWhen (> 0.5) $ struct "t*4" $ (tri :: Pattern Double) + 1
532532
let res = queryArc fil (Arc 0.5 1.5)
533-
property $ fmap toEvent [(((3 % 4, 1), (3 % 4, 1)), 1.25), (((1, 5 % 4), (1, 5 % 4)), 1.25), (((5 % 4, 3 % 2), (5 % 4, 3 % 2)), 1.75)] === res
533+
property $ fmap toEvent [(((3 % 4, 1), (3 % 4, 1)), 1.5), (((1, 5 % 4), (1, 5 % 4)), 1), (((5 % 4, 3 % 2), (5 % 4, 3 % 2)), 1.5)] === res
534534

535535
describe "compressArc" $ do
536536
it "return empty if start time is greater than end time" $ do

test/Sound/Tidal/UITest.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ run =
4242
compareP
4343
(Arc 0 3)
4444
(segment 4 saw)
45-
("0.125 0.375 0.625 0.875" :: Pattern Double)
45+
("0 0.25 0.5 0.75" :: Pattern Double)
4646
it "can hold a value over multiple cycles" $ do
4747
comparePD
4848
(Arc 0 8)
@@ -377,7 +377,7 @@ run =
377377
compareP
378378
(Arc 0 4)
379379
("0" |+ chooseBy (sig fromRational) [0, 1, 2, 3])
380-
("2" :: Pattern Int)
380+
("0" :: Pattern Int)
381381

382382
describe "arpeggiate" $ do
383383
it "can arpeggiate" $ do
@@ -479,4 +479,4 @@ run =
479479
compareP
480480
(Arc 0 1)
481481
(segment 2 $ quantise 1 $ sine :: Pattern Note)
482-
("1 0" :: Pattern Note)
482+
("0 1" :: Pattern Note)

0 commit comments

Comments
 (0)