diff --git a/.github/workflows/listener-build-linux.yml b/.github/workflows/listener-build-linux.yml deleted file mode 100644 index 8cd8512d9..000000000 --- a/.github/workflows/listener-build-linux.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: build-listener-linux - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - ghc: ['9.0.1'] - cabal: ['3.4.0.0'] - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Setup Haskell - uses: haskell/actions/setup@v1 - id: setup-haskell-cabal - with: - ghc-version: ${{ matrix.ghc }} - cabal-version: ${{ matrix.cabal }} - - - name: Freeze - run: cabal freeze - - - name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle - uses: actions/cache@v2 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - dist-newstyle - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('tidal-listener/src') }} - - - name: cabal update and build - run: | - cabal update - cabal build --enable-tests tidal-listener - cabal build - - - name: move GHC libs and configs - run: | - mkdir -p tidal-listener/binary/haskell-libs/ghc-packages/ - cp -r ${{ steps.setup-haskell-cabal.outputs.ghc-path }}/../lib/ghc-${{ matrix.ghc }}/* tidal-listener/binary/haskell-libs/ghc-packages - - - name: move installed packages - run: | - mkdir -p tidal-listener/binary/haskell-libs/packages/ - cp -r ${{ steps.setup-haskell-cabal.outputs.cabal-store }}/ghc-${{ matrix.ghc }}/* tidal-listener/binary/haskell-libs/packages - ls tidal-listener/binary/haskell-libs/packages - - - name: change paths in config files (GHC) - run: | - mv tidal-listener/binary/haskell-libs/ghc-packages/package.conf.d tidal-listener/binary/haskell-libs/package.conf.d - sed -i 's/\/opt\/ghc\/${{ matrix.ghc }}\/lib\/ghc-${{ matrix.ghc }}/${pkgroot}\/ghc-packages/g' tidal-listener/binary/haskell-libs/package.conf.d/* - - - name: change paths in config files (cabal) - run: | - mv tidal-listener/binary/haskell-libs/packages/package.db tidal-listener/binary/haskell-libs/package.db - sed -i 's/\/home\/runner\/.cabal\/store\/ghc-${{ matrix.ghc }}/${pkgroot}\/packages/g' tidal-listener/binary/haskell-libs/package.db/* - - - name: move ghc settings etc - run: | - mv tidal-listener/binary/haskell-libs/ghc-packages/settings tidal-listener/binary/haskell-libs/settings - mv tidal-listener/binary/haskell-libs/ghc-packages/platformConstants tidal-listener/binary/haskell-libs/platformConstants - mv tidal-listener/binary/haskell-libs/ghc-packages/llvm-targets tidal-listener/binary/haskell-libs/llvm-targets - mv tidal-listener/binary/haskell-libs/ghc-packages/llvm-passes tidal-listener/binary/haskell-libs/llvm-passes - - - name: ghc-pkg recache - run: | - ghc-pkg --package-db=tidal-listener/binary/haskell-libs/package.conf.d recache - ghc-pkg --package-db=tidal-listener/binary/haskell-libs/package.db recache - ghc-pkg --package-db=tidal-listener/binary/haskell-libs/package.conf.d --package-db=tidal-listener/binary/haskell-libs/package.db check - - - name: move c-libs - run: | - mkdir -p tidal-listener/binary/c-libs/ - cp /usr/lib/x86_64-linux-gnu/libz.so.1 tidal-listener/binary/c-libs/libz.so.1 - cp /usr/lib/x86_64-linux-gnu/libtinfo.so.6 tidal-listener/binary/c-libs/libtinfo.so.6 - cp /usr/lib/x86_64-linux-gnu/librt.so.1 tidal-listener/binary/c-libs/librt.so.1 - cp /usr/lib/x86_64-linux-gnu/libutil.so.1 tidal-listener/binary/c-libs/libutil.so.1 - cp /usr/lib/x86_64-linux-gnu/libpthread.so.0 tidal-listener/binary/c-libs/libpthread.so.0 - cp /usr/lib/x86_64-linux-gnu/libm.so.6 tidal-listener/binary/c-libs/libm.so.6 - cp /usr/lib/x86_64-linux-gnu/libgmp.so.10 tidal-listener/binary/c-libs/libgmp.so.10 - cp /usr/lib/x86_64-linux-gnu/libc.so.6 tidal-listener/binary/c-libs/libc.so.6 - cp /usr/lib/x86_64-linux-gnu/libdl.so.2 tidal-listener/binary/c-libs/libdl.so.2 - ln -s /usr/lib/x86_64-linux-gnu/libz.so.1 tidal-listener/binary/c-libs/libz.so - ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 tidal-listener/binary/c-libs/libtinfo.so - ln -s /usr/lib/x86_64-linux-gnu/librt.so.1 tidal-listener/binary/c-libs/librt.so - ln -s /usr/lib/x86_64-linux-gnu/libutil.so.1 tidal-listener/binary/c-libs/libutil.so - ln -s /usr/lib/x86_64-linux-gnu/libpthread.so.0 tidal-listener/binary/c-libs/libpthread.so - ln -s /usr/lib/x86_64-linux-gnu/libm.so.6 tidal-listener/binary/c-libs/libm.so - ln -s /usr/lib/x86_64-linux-gnu/libgmp.so.10 tidal-listener/binary/c-libs/libgmp.so - ln -s /usr/lib/x86_64-linux-gnu/libc.so.6 tidal-listener/binary/c-libs/libc.so - ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 tidal-listener/binary/c-libs/libdl.so - - - name: remove unneccessary libs - run: | - cd tidal-listener/binary/haskell-libs/ghc-packages - rm -r ghc-${{ matrix.ghc }} - rm -r Cabal-* - - - name: fake gcc - run: | - mkdir -p tidal-listener/binary/haskell-libs/bin/ - cp tidal-listener/fake_gcc.sh tidal-listener/binary/haskell-libs/bin/fake_gcc.sh - sed -i 's/cc/bin\/fake_gcc.sh/g' tidal-listener/binary/haskell-libs/settings - chmod 755 tidal-listener/binary/haskell-libs/bin/fake_gcc.sh - - - name: move executable - run: | - cp dist-newstyle/build/x86_64-linux/ghc-${{ matrix.ghc }}/tidal-listener-0.1.0.0/x/tidal-listener/build/tidal-listener/tidal-listener tidal-listener/binary/tidal-listener - # cp dist-newstyle/build/x86_64-linux/ghc-${{ matrix.ghc }}/tidal-*/x/tidal/build/tidal/tidal tidal-listener/binary/tidal - - - name: zip files - run: | - cd tidal-listener/ - mv binary tidal - tar cvfj linux.tar tidal/* - - - uses: actions/upload-artifact@v2 - with: - path: tidal-listener/linux.tar - - release: - runs-on: ubuntu-latest - needs: build - if: startsWith(github.ref, 'refs/tags/') - steps: - - uses: actions/download-artifact@v2 - - run: ls */* - - - uses: softprops/action-gh-release@v1 - with: - files: artifact/linux.tar diff --git a/.github/workflows/listener-build-macosx.yml b/.github/workflows/listener-build-macosx.yml deleted file mode 100644 index 7cd4f8eb1..000000000 --- a/.github/workflows/listener-build-macosx.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: build-listener-macosx - -on: [push, pull_request] - -jobs: - build: - - runs-on: macOS-latest - strategy: - matrix: - ghc: ['9.0.1'] - cabal: ['3.4.0.0'] - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Setup Haskell - uses: haskell/actions/setup@v1 - id: setup-haskell-cabal - with: - ghc-version: ${{ matrix.ghc }} - cabal-version: ${{ matrix.cabal }} - - - name: Freeze - run: | - cabal freeze - - - name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle - uses: actions/cache@v2 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - dist-newstyle - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('tidal-listener/src') }} - - - name: cabal update and build - run: | - cabal update - cabal build --enable-tests tidal-listener - cabal build - - - name: move GHC libs and configs - run: | - mkdir -p tidal-listener/binary/haskell-libs/ghc-packages/ - cp -r ${{ steps.setup-haskell-cabal.outputs.ghc-path }}/../lib/ghc-${{ matrix.ghc }}/* tidal-listener/binary/haskell-libs/ghc-packages - - - name: move installed packages - run: | - mkdir -p tidal-listener/binary/haskell-libs/packages/ - cp -r ${{ steps.setup-haskell-cabal.outputs.cabal-store }}/ghc-${{ matrix.ghc }}/* tidal-listener/binary/haskell-libs/packages - ls tidal-listener/binary/haskell-libs/packages - - - name: change paths in config files (GHC) - run: | - export LANG=C - export LC_CTYPE=C - export LC_ALL=C - mv tidal-listener/binary/haskell-libs/ghc-packages/package.conf.d tidal-listener/binary/haskell-libs/package.conf.d - sed -i '' 's+/Users/runner/.ghcup/ghc/${{ matrix.ghc }}/lib/ghc-${{ matrix.ghc }}+${pkgroot}/ghc-packages+g' tidal-listener/binary/haskell-libs/package.conf.d/* - - - name: change paths in config files (cabal) - run: | - export LANG=C - export LC_CTYPE=C - export LC_ALL=C - mv tidal-listener/binary/haskell-libs/packages/package.db tidal-listener/binary/haskell-libs/package.db - sed -i '' 's+/Users/runner/.cabal/store/ghc-8.10.1+${pkgroot}/packages+g' tidal-listener/binary/haskell-libs/package.db/* - - - name: move ghc settings etc - run: | - mv tidal-listener/binary/haskell-libs/ghc-packages/settings tidal-listener/binary/haskell-libs/settings - mv tidal-listener/binary/haskell-libs/ghc-packages/platformConstants tidal-listener/binary/haskell-libs/platformConstants - mv tidal-listener/binary/haskell-libs/ghc-packages/llvm-targets tidal-listener/binary/haskell-libs/llvm-targets - mv tidal-listener/binary/haskell-libs/ghc-packages/llvm-passes tidal-listener/binary/haskell-libs/llvm-passes - - - name: ghc-pkg recache - run: | - ghc-pkg --package-db=tidal-listener/binary/haskell-libs/package.conf.d recache - ghc-pkg --package-db=tidal-listener/binary/haskell-libs/package.db recache - ghc-pkg --package-db=tidal-listener/binary/haskell-libs/package.conf.d --package-db=tidal-listener/binary/haskell-libs/package.db check - - - name: remove unneccessary libs - run: | - cd tidal-listener/binary/haskell-libs/ghc-packages - rm -r ghc-${{ matrix.ghc }} - rm -r Cabal-* - rm -r rts - - - name: fake gcc - run: | - export LANG=C - export LC_CTYPE=C - export LC_ALL=C - mkdir -p tidal-listener/binary/haskell-libs/bin/ - cp -r tidal-listener/fake_gcc.sh tidal-listener/binary/haskell-libs/bin/fake_gcc.sh - sed -i '' 's+gcc+$topdir/bin/fake_gcc.sh+g' tidal-listener/binary/haskell-libs/settings - chmod 755 tidal-listener/binary/haskell-libs/bin/fake_gcc.sh - - - name: move executables - run: | - cp -r dist-newstyle/build/x86_64-osx/ghc-${{ matrix.ghc }}/tidal-listener-0.1.0.0/x/tidal-listener/build/tidal-listener/tidal-listener tidal-listener/binary/tidal-listener - # cp -r dist-newstyle/build/x86_64-osx/ghc-${{ matrix.ghc }}/tidal-*/x/tidal/build/tidal/tidal tidal-listener/binary/tidal - - - name: zip files - run: | - cd tidal-listener/ - tar cvfj macosx.tar binary/* - - - uses: actions/upload-artifact@v2 - with: - path: tidal-listener/macosx.tar - - release: - runs-on: ubuntu-latest - needs: build - if: startsWith(github.ref, 'refs/tags/') - steps: - - uses: actions/download-artifact@v2 - - run: ls */* - - - uses: softprops/action-gh-release@v1 - with: - files: artifact/macosx.tar diff --git a/.github/workflows/listener-build-windows.yml b/.github/workflows/listener-build-windows.yml deleted file mode 100644 index 1ee1b6bdb..000000000 --- a/.github/workflows/listener-build-windows.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: build-listener-windows - -on: [push, pull_request] - -jobs: - build: - - runs-on: windows-latest - strategy: - matrix: - ghc: ['9.0.1'] - cabal: ['3.4.0.0'] - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Setup Haskell - uses: haskell/actions/setup@v1 - id: setup-haskell-cabal - with: - ghc-version: ${{ matrix.ghc }} - cabal-version: ${{ matrix.cabal }} - - - name: Freeze - run: | - cabal freeze - - - name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle - uses: actions/cache@v2 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - dist-newstyle - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('tidal-listener/src') }} - - - name: cabal build - run: | - cabal update - cabal build --enable-tests tidal-listener - cabal build - - - name: remove unneccessary libs - run: | - Remove-Item 'C:\tools\ghc-${{ matrix.ghc }}\lib\ghc-${{ matrix.ghc }}' -Recurse -ErrorAction Ignore - Remove-Item 'C:\tools\ghc-${{ matrix.ghc }}\lib\Cabal-*' -Recurse -ErrorAction Ignore - Remove-Item 'C:\tools\ghc-${{ matrix.ghc }}\lib\rts' -Recurse -ErrorAction Ignore - - - name: move GHC libs and configs - run: | - Copy-Item -Path 'C:\tools\ghc-${{ matrix.ghc }}\lib\' -Recurse -Destination 'tidal-listener\binary\haskell-libs\ghc-packages' - Move-Item -Path 'tidal-listener\binary\haskell-libs\ghc-packages\settings' -Destination 'tidal-listener\binary\haskell-libs\settings' - Move-Item -Path 'tidal-listener\binary\haskell-libs\ghc-packages\llvm-passes' -Destination 'tidal-listener\binary\haskell-libs\llvm-passes' - Move-Item -Path 'tidal-listener\binary\haskell-libs\ghc-packages\llvm-targets' -Destination 'tidal-listener\binary\haskell-libs\llvm-targets' - Move-Item -Path 'tidal-listener\binary\haskell-libs\ghc-packages\platformConstants' -Destination 'tidal-listener\binary\haskell-libs\platformConstants' - - - name: move mingw - run: Copy-Item -Path 'C:\tools\ghc-${{ matrix.ghc }}\mingw\' -Recurse -Destination 'tidal-listener\binary\mingw' - - - name: move installed packages - run: Copy-Item -Path 'C:\sr\ghc-${{ matrix.ghc }}\' -Recurse -Destination 'tidal-listener\binary\haskell-libs\packages' - - - name: change paths in config files (packages) - run: | - Move-Item -Path 'tidal-listener\binary\haskell-libs\packages\package.db\' -Destination 'tidal-listener\binary\haskell-libs\package.db\' - $configs = Get-ChildItem 'tidal-listener\binary\haskell-libs\package.db\' -Recurse - $configs | %{ (gc $_) -replace "C:\\sr\\ghc-${{ matrix.ghc }}", '$topdir\packages' | Set-Content $_.fullname} - - - name: move ghc package config - run: | - Move-Item -Path 'tidal-listener\binary\haskell-libs\ghc-packages\package.conf.d\' -Destination 'tidal-listener\binary\haskell-libs\package.conf.d\' - $configs = Get-ChildItem 'tidal-listener\binary\haskell-libs\package.conf.d\' -Recurse - $configs | %{ (gc $_) -replace 'topdir', 'topdir\ghc-packages' | Set-Content $_.fullname} - - - name: ghc-pkg recache - run: | - $ENV:GHC_PACKAGE_PATH="tidal-listener\binary\haskell-libs\package.conf.d;tidal-listener\binary\haskell-libs\package.db" - ghc-pkg -v2 recache --package-db="tidal-listener\binary\haskell-libs\package.conf.d" - ghc-pkg -v2 recache --package-db="tidal-listener\binary\haskell-libs\package.db" - - - name: move executables - run: | - Copy-Item -Path 'dist-newstyle\build\x86_64-windows\ghc-${{ matrix.ghc }}\tidal-listener-0.1.0.0\x\tidal-listener\build\tidal-listener\tidal-listener.exe' -Recurse -Destination 'tidal-listener\binary\tidal-listener.exe' - # Copy-Item -Path 'dist-newstyle\build\x86_64-windows\ghc-${{ matrix.ghc }}\tidal-*\x\tidal\build\tidal\tidal.exe' -Recurse -Destination 'tidal-listener\binary\tidal.exe' - - - name: zip files - run: Compress-Archive -LiteralPath 'tidal-listener\binary\' -DestinationPath 'tidal-listener\windows.zip' - - - uses: actions/upload-artifact@v2 - with: - path: tidal-listener\windows.zip - - release: - runs-on: ubuntu-latest - needs: build - if: startsWith(github.ref, 'refs/tags/') - steps: - - uses: actions/download-artifact@v2 - - run: ls */* - - - uses: softprops/action-gh-release@v1 - with: - files: artifact/windows.zip diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index b761710b4..dd470c8f9 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.4.0 - - uses: cachix/install-nix-action@v16 + - uses: cachix/install-nix-action@v22 with: nix_path: nixpkgs=channel:nixos-unstable - run: nix fmt -- --check ./ @@ -31,12 +31,12 @@ jobs: needs: cancel-previous-runs strategy: matrix: - package: [tidal, tidal-link, tidal-listener, tidal-parse] + package: [tidal, tidal-link] os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2.4.0 - - uses: cachix/install-nix-action@v16 + - uses: cachix/install-nix-action@v22 with: nix_path: nixpkgs=channel:nixos-unstable - run: nix build --print-build-logs --no-update-lock-file .#${{ matrix.package }} diff --git a/bench/Memory/Tidal/Inputs.hs b/bench/Memory/Tidal/Inputs.hs index eb731262b..bc0ba16bf 100644 --- a/bench/Memory/Tidal/Inputs.hs +++ b/bench/Memory/Tidal/Inputs.hs @@ -3,7 +3,6 @@ module Tidal.Inputs where import Sound.Tidal.Context hiding (Live) -import Sound.Tidal.Signal.Compose ((#), (|*|)) import Weigh columns :: Weigh () diff --git a/bench/Memory/Tidal/UIB.hs b/bench/Memory/Tidal/UIB.hs index 9d416d2e0..a532a6b31 100644 --- a/bench/Memory/Tidal/UIB.hs +++ b/bench/Memory/Tidal/UIB.hs @@ -16,4 +16,4 @@ euclidB = columns func "euclid" (euclid (head ecA1) (head $ drop 1 ecA1)) ecA2 func "euclidFull" (euclidFull (head ecA1) (head $ drop 1 ecA1) ecA2) ecA2 - func "euclidBool" (_euclidBool 1) 100000 + func "euclidBool" (_euclidBool 1 :: Int -> Signal Bool) 100000 diff --git a/bench/Speed/Main.hs b/bench/Speed/Main.hs index 5d4c8f46a..8c1395ad9 100644 --- a/bench/Speed/Main.hs +++ b/bench/Speed/Main.hs @@ -1,12 +1,18 @@ module Main where -import Criterion.Main -import Tidal.PatternB -import Tidal.CoreB -import Tidal.UIB +import Criterion.Main (defaultMain) +import Tidal.CoreB +import Tidal.PatternB +import Tidal.UIB -patternBs :: [IO ()] -patternBs = defaultMain <$> [withQueryTimeB, withQueryArcB, withResultArcB, withQueryTimeB, subArcB] +patternBs :: [IO ()] +patternBs = defaultMain <$> [ withQueryTimeB + , withEventArcB + , withQueryArcB + , maybeSectB + , [sectB] + , [hullB] + ] coreBs :: [IO ()] coreBs = defaultMain <$> [fromListB, stackB, appendB, concatB, _fastB] @@ -16,7 +22,6 @@ uiBs = defaultMain <$> [euclidB, fixB] main :: IO () main = do - _ <- sequence coreBs - _ <- sequence patternBs - _ <- sequence uiBs - return () + sequence_ coreBs + sequence_ patternBs + sequence_ uiBs diff --git a/bench/Speed/Tidal/CoreB.hs b/bench/Speed/Tidal/CoreB.hs index 1510351f3..cf938e657 100644 --- a/bench/Speed/Tidal/CoreB.hs +++ b/bench/Speed/Tidal/CoreB.hs @@ -9,7 +9,7 @@ _fastB :: [Benchmark] _fastB = [ bgroup "_fast" [ bench "_fast < 0" $ whnf (_fast (-2)) pattApp2 - , bench "_fast > 0" $ whnf (_fast (toTime $ 10^6)) (cat catPattBig) ] + , bench "_fast > 0" $ whnf (_fast (10^6)) (cat catPattBig) ] ] concatB :: [Benchmark] @@ -23,16 +23,21 @@ concatB = , bench "timeCat 10^6" $ whnf timeCat timeCatBig ] ] +signalFromList :: [Time] -> Signal Time +signalFromList = fromList +signalFastFromList :: [Time] -> Signal Time +signalFastFromList = fastFromList + fromListB :: [Benchmark] fromListB = [ bgroup "fromList" [ - bench "fromList" $ whnf fromList xs6 - , bench "fromList nf" $ nf fromList xs6 - , bench "fastFromList 10^3" $ whnf fastFromList xs3 - , bench "fastFromList 10^4" $ whnf fastFromList xs4 - , bench "fastFromList 10^5" $ whnf fastFromList xs5 - , bench "fastFromList 10^6" $ whnf fastFromList xs6 - , bench "fastFromList 10^6 nf" $ nf fastFromList xs6 ] + bench "fromList" $ whnf signalFromList xs6 + , bench "fromList nf" $ nf signalFromList xs6 + , bench "fastFromList 10^3" $ whnf signalFastFromList xs3 + , bench "fastFromList 10^4" $ whnf signalFastFromList xs4 + , bench "fastFromList 10^5" $ whnf signalFastFromList xs5 + , bench "fastFromList 10^6" $ whnf signalFastFromList xs6 + , bench "fastFromList 10^6 nf" $ nf signalFastFromList xs6 ] ] appendB :: [Benchmark] diff --git a/bench/Speed/Tidal/PatternB.hs b/bench/Speed/Tidal/PatternB.hs index aafecd8f1..39580bf4a 100644 --- a/bench/Speed/Tidal/PatternB.hs +++ b/bench/Speed/Tidal/PatternB.hs @@ -1,45 +1,48 @@ -module Tidal.PatternB where +module Tidal.PatternB where -import Criterion.Main -import Tidal.Inputs -import Sound.Tidal.Pattern +import Criterion.Main (Benchmark, bench, bgroup, nf, whnf) +import Sound.Tidal.Arc (hull, maybeSect, sect) +import Sound.Tidal.Signal.Base (withEventArc, withQueryArc, + withQueryTime) +import Sound.Tidal.Types (ArcF (Arc)) +import Tidal.Inputs (arcFunc, wqaBig, wqaMed) -arc1 = Arc 3 5 +arc1 = Arc 3 5 arc2 = Arc 4 6 arc3 = Arc 0 1 arc4 = Arc 1 2 -withQueryTimeB :: [Benchmark] -withQueryTimeB = +withQueryTimeB :: [Benchmark] +withQueryTimeB = [ bgroup "withQueryTime" [ - bench "wqt whnf" $ whnf withQueryTime (*2) + bench "wqt whnf" $ whnf withQueryTime (*2) , bench "wqt2 whnf" $ whnf withQueryTime (+1) , bench "wqt nf" $ nf withQueryTime (*2) ] ] -withResultArcB :: [Benchmark] -withResultArcB = - [ bgroup "withResultArc" [ - bench "wqa med" $ whnf (withResultArc arcFunc) wqaMed - , bench "wqa big" $ whnf (withResultArc arcFunc) wqaBig ] +withEventArcB :: [Benchmark] +withEventArcB = + [ bgroup "withEventArc" [ + bench "wqa med" $ whnf (withEventArc arcFunc) wqaMed + , bench "wqa big" $ whnf (withEventArc arcFunc) wqaBig ] ] withQueryArcB :: [Benchmark] -withQueryArcB = +withQueryArcB = [ bgroup "withQueryArc" [ bench "wqa med" $ whnf (withQueryArc arcFunc) wqaMed , bench "wqa big" $ whnf (withQueryArc arcFunc) wqaBig ] ] -subArcB :: [Benchmark] -subArcB = - [ bgroup "subArc" [ - bench "intersecting" $ whnf (subArc arc1) arc2 - , bench "non-intersecting" $ whnf (subArc arc3) arc4 ] +maybeSectB :: [Benchmark] +maybeSectB = + [ bgroup "maybeSect" [ + bench "intersecting" $ whnf (maybeSect arc1) arc2 + , bench "non-intersecting" $ whnf (maybeSect arc3) arc4 ] ] -sectB :: Benchmark +sectB :: Benchmark sectB = bench "sect" $ whnf (sect arc1) arc2 -hullB :: Benchmark +hullB :: Benchmark hullB = bench "hull" $ whnf (hull arc1) arc2 diff --git a/bench/Speed/Tidal/UIB.hs b/bench/Speed/Tidal/UIB.hs index 3f41cdd39..92be4d68b 100644 --- a/bench/Speed/Tidal/UIB.hs +++ b/bench/Speed/Tidal/UIB.hs @@ -18,5 +18,5 @@ euclidB = [ bgroup "euclid" [ bench "euclid" $ whnf (euclid (head ecA1) (head $ drop 1 ecA1)) ecA2 , bench "euclidFull" $ whnf (euclidFull (head ecA1) (head $ drop 1 ecA1) ecA2) ecA2 - , bench "euclidBool" $ whnf (_euclidBool 1) 100000] + , bench "euclidBool" $ whnf (_euclidBool 1 :: Int -> Signal Bool) 100000] ] diff --git a/cabal.project b/cabal.project index a37eb5397..77fc96d43 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1 @@ -packages: ./ tidal-listener tidal-link +packages: ./ tidal-link diff --git a/flake.lock b/flake.lock index 090f8fa7f..1070cd5e9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,29 @@ { "nodes": { + "hosc": { + "flake": false, + "locked": { + "lastModified": 1669944828, + "narHash": "sha256-cHEf0yEiwNnEpDj7SSQWRMUEAT5USHuuUCPuzOXHWrk=", + "owner": "rd--", + "repo": "hosc", + "rev": "e77aa67cd0b99a32498fef246a687ba443c9b4be", + "type": "github" + }, + "original": { + "owner": "rd--", + "repo": "hosc", + "rev": "e77aa67cd0b99a32498fef246a687ba443c9b4be", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1667629849, - "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", + "lastModified": 1687807295, + "narHash": "sha256-7TUD0p0m4mZpIi1O+Cyk5NCqpJUnhv/CJOAuHOndjao=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3bacde6273b09a21a8ccfba15586fb165078fb62", + "rev": "6b3d1b1cf13f407fef5e634b224d575eb7211975", "type": "github" }, "original": { @@ -18,17 +35,36 @@ }, "root": { "inputs": { + "hosc": "hosc", "nixpkgs": "nixpkgs", "utils": "utils" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fe2d0e36a..8a8801d6f 100644 --- a/flake.nix +++ b/flake.nix @@ -5,8 +5,6 @@ Packages are included for: - tidal - tidal-link - - tidal-listener - - tidal-parse A `tidal-ghci` package is also included. This is a small script that starts an instance of `GHCi` with `Tidal` installed and with the `BootTidal.hs` @@ -23,6 +21,14 @@ inputs = { utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + # Temporarily add `hosc` at the latest v0.20 commit + # (nixpkgs currently only has 0.19.1). + # See this comment for details: + # https://github.com/tidalcycles/Tidal/pull/1022#issuecomment-1610978403 + hosc = { + url = "github:rd--/hosc?rev=e77aa67cd0b99a32498fef246a687ba443c9b4be"; + flake = false; + }; }; outputs = inputs: let @@ -38,18 +44,15 @@ mkPackages = pkgs: let project = pkgs.haskellPackages.extend (pkgs.haskell.lib.compose.packageSourceOverrides { + hosc = inputs.hosc; # Remove once `hosc` is at 0.20 in nixpkgs. tidal = ./.; tidal-link = ./tidal-link; - tidal-listener = ./tidal-listener; - tidal-parse = ./tidal-parse; }); tidal-boot = ./BootTidal.hs; tidal-ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: [project.tidal]); in { tidal = project.tidal; tidal-link = project.tidal-link; - tidal-listener = project.tidal-listener; - tidal-parse = project.tidal-parse; tidal-ghci = pkgs.writeShellScriptBin "tidal-ghci" '' ${tidal-ghc}/bin/ghci -ghci-script ${tidal-boot} ''; diff --git a/stack.yaml b/stack.yaml index f7359b5af..b6b57431c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -2,11 +2,8 @@ resolver: lts-20.5 packages: - '.' - - 'tidal-parse' - 'tidal-link' extra-deps: - hosc-0.20 - haskellish-0.3.2.1 - - diff --git a/test/Sound/Tidal/SequenceTest.hs b/test/Sound/Tidal/SequenceTest.hs index e91d7e40d..fc2976953 100644 --- a/test/Sound/Tidal/SequenceTest.hs +++ b/test/Sound/Tidal/SequenceTest.hs @@ -2,15 +2,24 @@ module Sound.Tidal.SequenceTest where -import Test.Microspec -import TestUtils +import Test.Microspec (MTestable (describe), Microspec, + Property, it, shouldBe) +import TestUtils (stripSequenceMetadata) import Prelude hiding ((*>), (<*)) -import Sound.Tidal.Pattern import Sound.Tidal.Sequence import Sound.Tidal.Signal.Base (queryArc) -import Sound.Tidal.Types +import Sound.Tidal.Types (ArcF (Arc), Direction (In, Out), + Event (Event), Metadata (Metadata), + Sequence (Atom, Cat), Signal, + Strategy (Centre, Expand), Time) + +shouldMatch :: (Eq a, Show a) => Sequence a -> Sequence a -> Property +shouldMatch seq1 seq2 = shouldBe (stripSequenceMetadata seq1) (stripSequenceMetadata seq2) + +tAtom :: Time -> Time -> Time -> Maybe a -> Sequence a +tAtom = Atom mempty run :: Microspec () run = @@ -18,36 +27,36 @@ run = describe "pairAligned" $ do it "Aligns pairs of events" $ do (pairAligned In ("10 20", "1 2") :: Sequence (Int, Int)) - `shouldBe` + `shouldMatch` Cat [step 1 (10,1), step 1 (20,2)] describe "pairAlign" $ do it "Can centre two sequences, paired into structure of the first one." $ do (pairAlign Centre In "10" "1 2") - `shouldBe` - (Cat [Atom 0.5 0 0 Nothing, - Atom 0.5 0 0.5 $ Just (10,1), - Atom 0.5 0.5 0 $ Just (10,2), - Atom 0.5 0 0 Nothing + `shouldMatch` + (Cat [tAtom 0.5 0 0 Nothing, + tAtom 0.5 0 0.5 $ Just (10,1), + tAtom 0.5 0.5 0 $ Just (10,2), + tAtom 0.5 0 0 Nothing ] :: Sequence (Int,Int)) describe "alignF" $ do it "Can align and combine two sequences by Expansion and addition" $ do ((alignF Expand In (+) "0 1 2" "10 20") :: Sequence Int) - `shouldBe` - (Cat [Atom 1 0 0 $ Just 10, Atom 0.5 0 0.5 $ Just 11, Atom 0.5 0.5 0 $ Just 21, - Atom 1 0 0 $ Just 22]) + `shouldMatch` + (Cat [tAtom 1 0 0 $ Just 10, tAtom 0.5 0 0.5 $ Just 11, tAtom 0.5 0.5 0 $ Just 21, + tAtom 1 0 0 $ Just 22]) it "Can align and combine subsequences by Expansion and addition" $ do ((alignF Expand In (+) "0 [1 2] 3" "10 20") :: Sequence Int) - `shouldBe` - (Cat [Atom 1 0 0 $ Just 10, Atom 0.5 0 0 $ Just 11, Atom 0.5 0 0 $ Just 22, - Atom 1 0 0 $ Just 23]) + `shouldMatch` + (Cat [tAtom 1 0 0 $ Just 10, tAtom 0.5 0 0 $ Just 11, tAtom 0.5 0 0 $ Just 22, + tAtom 1 0 0 $ Just 23]) it "Can align and combine subsequences by Expansion and addition" $ do ((alignF Expand In (+) "0 [1 2] 3" "10 [20 30]") :: Sequence Int) - `shouldBe` - (Cat [Atom 1 0 0 $ Just 10, Atom 0.5 0 0 $ Just 11, Atom 0.5 0 0 $ Just 22, - Atom 0.25 0 0.75 $ Just 23, Atom 0.75 0.25 0 $ Just 33]) + `shouldMatch` + (Cat [tAtom 1 0 0 $ Just 10, tAtom 0.5 0 0 $ Just 11, tAtom 0.5 0 0 $ Just 22, + tAtom 0.25 0 0.75 $ Just 23, tAtom 0.75 0.25 0 $ Just 33]) describe "beatMode" $ do it "Can turn a sequence into a signal" $ do - (queryArc ((seqToSignal' ( alignF Centre Out (+) ("10 20 30") ("1 2")) :: Signal Int)) (Arc 0 1)) + (queryArc ((seqToSignal' (stripSequenceMetadata $ alignF Centre Out (+) ("10 20 30") ("1 2")) :: Signal Int)) (Arc 0 1)) `shouldBe` [Event (Metadata []) (Just $ Arc (1/6) (1/2)) (Arc (1/6) (1/3)) 11, Event (Metadata []) (Just $ Arc (1/6) (1/2)) (Arc (1/3) (1/2)) 21, diff --git a/test/Sound/Tidal/SignalBaseTest.hs b/test/Sound/Tidal/SignalBaseTest.hs index ce7755fa3..bec405fd7 100644 --- a/test/Sound/Tidal/SignalBaseTest.hs +++ b/test/Sound/Tidal/SignalBaseTest.hs @@ -2,27 +2,33 @@ module Sound.Tidal.SignalBaseTest where -import Test.Microspec -import TestUtils +import Test.Microspec (MTestable (describe), Microspec, + Testable (property), it, shouldBe, + (===)) +import TestUtils (compareP, comparePD, + stripMetadata, toEvent) import Prelude hiding ((*>), (<*)) import Data.List (sort) -import Data.Ratio +import Data.Ratio ((%)) import Sound.Tidal.Compose (struct, (|+), (|=|)) import Sound.Tidal.Params (n, s) import Sound.Tidal.ParseBP (parseBP_E) -import Sound.Tidal.Pattern (_slow, append, atom, cat, euclid, - every, fast, fastCat, - filterValues, ply, press, pressBy, - range, rev, run, silence, slow, - stack, superimpose, timeCat, (*>), - (<*)) +import Sound.Tidal.Pattern (Pattern (atom, filterValues, rev, silence, stack, timeCat, (*>), (<*)), + _slow, append, cat, early, euclid, + euclidFull, euclidInv, every, + fast, fastCat, late, ply, press, + pressBy, range, run, slow, + superimpose, (<~)) import Sound.Tidal.Signal.Base import Sound.Tidal.Signal.Random (irand) import Sound.Tidal.Signal.Waveform (saw, sine, tri) -import Sound.Tidal.Types +import Sound.Tidal.Types (ArcF (Arc), Event (Event), + Metadata (Metadata), Note, + Signal (query), State (State), + Time, Value (VF)) import qualified Data.Map.Strict as Map diff --git a/test/TestUtils.hs b/test/TestUtils.hs index b09169fa5..07562ca9b 100644 --- a/test/TestUtils.hs +++ b/test/TestUtils.hs @@ -61,3 +61,8 @@ stripMetadata = setMetadata $ Metadata [] toEvent :: (((Time, Time), (Time, Time)), a) -> Event a toEvent (((ws, we), (ps, pe)), v) = Event (Metadata []) (Just $ Arc ws we) (Arc ps pe) v + +stripSequenceMetadata :: Sequence a -> Sequence a +stripSequenceMetadata = withAtom f + where f (Atom _ d i o v) = Atom mempty d i o v + f x = x diff --git a/tidal-listener/tidal-listener.cabal b/tidal-listener/tidal-listener.cabal index b0fe4acf8..1396ac49d 100644 --- a/tidal-listener/tidal-listener.cabal +++ b/tidal-listener/tidal-listener.cabal @@ -35,8 +35,9 @@ library default-language: Haskell2010 ghc-options: -threaded -Wall - -dynamic -- see: https://github.com/haskell-hint/hint/issues/156 + if !os(windows) + ghc-options: -dynamic-too executable tidal-listener @@ -48,5 +49,6 @@ executable tidal-listener default-language: Haskell2010 ghc-options: -threaded -Wall - -dynamic -- see: https://github.com/haskell-hint/hint/issues/156 + if !os(windows) + ghc-options: -dynamic-too