From aa7a90d01de75c10f2fe7df1fcec049a78ea73eb Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 19:04:44 +0200 Subject: [PATCH 01/13] Bump haskell.nix --- default.nix | 14 +++++++------- nix/sources.json | 6 +++--- tttool.cabal | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/default.nix b/default.nix index b47ae3f7..d3b820b3 100644 --- a/default.nix +++ b/default.nix @@ -34,8 +34,8 @@ let ]; # Pinning the input to the constraint solver - compiler-nix-name = "ghc924"; - index-state = "2022-11-04T00:00:00Z"; + compiler-nix-name = "ghc928"; + index-state = "2023-07-14T00:00:00Z"; plan-sha256 = sha256; inherit checkMaterialization; @@ -83,15 +83,15 @@ let in rec { shell = tttool-shell pkgs - "1i97b1n9jpn94218ixdg27ysq3ncizm3v6d3ivl5l63qc2010cbr"; + "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; linux-exe = tttool-exe pkgs - "1i97b1n9jpn94218ixdg27ysq3ncizm3v6d3ivl5l63qc2010cbr"; + "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; windows-exe = tttool-exe pkgs.pkgsCross.mingwW64 - "0y2ri2ww7d39dgqxmjz9m00ybmxcpr624cafhq1zdhmizyknirzj"; + "1x16mjjx4wnzksmpi4jg6ykvfvdshrhp58gciy9lfslavy9clf3a"; static-exe = tttool-exe pkgs.pkgsCross.musl64 - "1i97b1n9jpn94218ixdg27ysq3ncizm3v6d3ivl5l63qc2010cbr"; + "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; osx-exe = tttool-exe pkgs-osx - "1i97b1n9jpn94218ixdg27ysq3ncizm3v6d3ivl5l63qc2010cbr"; + "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; osx-exe-bundle = osx-bundler pkgs-osx osx-exe; static-files = sourceByRegex ./. [ diff --git a/nix/sources.json b/nix/sources.json index f5977dd5..f46392b9 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://input-output-hk.github.io/haskell.nix", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "76292760f14ed5514670f0c226091babb6529218", - "sha256": "00iyixg65v5xmdr5lggsp7rvbvlbf0p9066dp5fhan61zmkq77yv", + "rev": "1ad94aea985af89856fcad0386a5a99a28c70218", + "sha256": "03v40kv1xnphf62a2k2dz2m4d1s2br5p63m3nfw5g8r0nf72xr3d", "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/76292760f14ed5514670f0c226091babb6529218.tar.gz", + "url": "https://github.com/input-output-hk/haskell.nix/archive/1ad94aea985af89856fcad0386a5a99a28c70218.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/tttool.cabal b/tttool.cabal index ad464a5b..5041687a 100644 --- a/tttool.cabal +++ b/tttool.cabal @@ -52,8 +52,8 @@ executable tttool build-depends: containers >= 0.4 && <0.7 build-depends: directory >= 1.2 && < 1.4 build-depends: executable-path == 0.0.* - build-depends: filepath == 1.3.* || == 1.4.* - build-depends: hashable == 1.3.* + build-depends: filepath >= 1.3 + build-depends: hashable >= 1.3 build-depends: haskeline == 0.8.* build-depends: HPDF >= 1.4.10 && < 1.5 build-depends: JuicyPixels >= 3.2.5 && < 3.4 From f4032690faa764271abf01709594c7f66e4683d3 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 19:10:50 +0200 Subject: [PATCH 02/13] Use IOHK cache --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db63ebec..7717babe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 + with: + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://cache.nixos.org/ - name: "Cachix: tttool" uses: cachix/cachix-action@v12 with: From c20a2480d3b209756504f616fc0ba9e4dbac7331 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 19:56:09 +0200 Subject: [PATCH 03/13] Fixes --- cabal.project | 2 +- default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index facc8bb0..90be9908 100644 --- a/cabal.project +++ b/cabal.project @@ -1,7 +1,7 @@ packages: . -- same as nix -with-compiler: ghc-9.2.4 +with-compiler: ghc-9.2.8 source-repository-package type: git diff --git a/default.nix b/default.nix index d3b820b3..b93fa0a1 100644 --- a/default.nix +++ b/default.nix @@ -91,7 +91,7 @@ in rec { static-exe = tttool-exe pkgs.pkgsCross.musl64 "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; osx-exe = tttool-exe pkgs-osx - "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; + "sha256-hy8KuisPm/9FWDHPsV5IGFCWl7+VAjezT1DBH0wE1Yk="; osx-exe-bundle = osx-bundler pkgs-osx osx-exe; static-files = sourceByRegex ./. [ From ae8a8e04892d393e6697572966fc54e3e6201316 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 19:56:53 +0200 Subject: [PATCH 04/13] Update freeze file --- cabal.project.freeze | 63 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/cabal.project.freeze b/cabal.project.freeze index 336dbc8a..fcf926f9 100644 --- a/cabal.project.freeze +++ b/cabal.project.freeze @@ -1,32 +1,34 @@ -- Run nix-shell -A check-cabal-freeze default.nix to update this file constraints: any.HPDF ==1.4.10, any.JuicyPixels ==3.3.7, - any.OneTuple ==0.3.1, - any.QuickCheck ==2.14.2, + any.OneTuple ==0.4.1.1, + any.QuickCheck ==2.14.3, any.StateVar ==1.2.2, - any.aeson ==2.1.1.0, - any.ansi-terminal ==0.11.3, + any.aeson ==2.1.2.1, + any.ansi-terminal ==1.0, + any.ansi-terminal-types ==0.11.5, any.ansi-wl-pprint ==0.6.9, any.array ==0.5.4.0, - any.assoc ==1.0.2, + any.assoc ==1.1, any.attoparsec ==0.14.4, - any.base ==4.16.3.0, - any.base-compat ==0.12.2, - any.base-compat-batteries ==0.12.2, - any.base-orphans ==0.8.7, + any.base ==4.16.4.0, + any.base-compat ==0.13.0, + any.base-compat-batteries ==0.13.0, + any.base-orphans ==0.9.0, any.base64-bytestring ==1.2.1.0, - any.bifunctors ==5.5.13, + any.bifunctors ==5.6.1, any.binary ==0.8.9.0, - any.bitvec ==1.1.3.0, + any.bitvec ==1.1.4.0, any.blaze-builder ==0.4.2.2, any.blaze-markup ==0.8.2.8, - any.blaze-svg ==0.3.6.1, - any.bytestring ==0.11.3.1, + any.blaze-svg ==0.3.7, + any.bytestring ==0.11.4.0, any.colour ==2.3.6, any.comonad ==5.0.8, - any.conduit ==1.3.4.3, + any.conduit ==1.3.5, any.containers ==0.6.5.1, any.contravariant ==1.5.5, + any.data-array-byte ==0.1.0.1, any.data-fix ==0.3.2, any.deepseq ==1.4.6.1, any.directory ==1.3.6.2, @@ -36,14 +38,15 @@ constraints: any.HPDF ==1.4.10, any.exceptions ==0.10.4, any.executable-path ==0.0.3.1, any.filepath ==1.4.2.2, - any.generically ==0.1, - any.ghc-bignum ==1.2, - any.ghc-boot-th ==9.2.4, + any.foldable1-classes-compat ==0.1, + any.generically ==0.1.1, + any.ghc-bignum ==1.3, + any.ghc-boot-th ==9.2.8, any.ghc-prim ==0.8.0, - any.hashable ==1.3.5.0, + any.hashable ==1.4.2.0, any.haskeline ==0.8.2, - any.indexed-traversable ==0.1.2, - any.indexed-traversable-instances ==0.1.1.1, + any.indexed-traversable ==0.1.2.1, + any.indexed-traversable-instances ==0.1.1.2, any.integer-logarithms ==1.0.3.1, any.libyaml ==0.1.2, any.mono-traversable ==1.0.15.3, @@ -52,37 +55,37 @@ constraints: any.HPDF ==1.4.10, any.optparse-applicative ==0.16.1.0, any.parsec ==3.1.15.0, any.pretty ==1.1.3.6, - any.primitive ==0.7.4.0, - any.process ==1.6.13.2, + any.primitive ==0.8.0.0, + any.process ==1.6.16.0, any.random ==1.1, any.resourcet ==1.3.0, any.rts ==1.0.2, any.safe ==0.3.19, any.scientific ==0.3.7.0, - any.semialign ==1.2.0.1, - any.semigroupoids ==5.3.7, + any.semialign ==1.3, + any.semigroupoids ==6.0.0.1, any.split ==0.2.3.5, any.splitmix ==0.1.0.4, any.spool ==0.1, any.stm ==2.5.0.2, - any.strict ==0.4.0.1, - any.tagged ==0.8.6.1, + any.strict ==0.5, + any.tagged ==0.8.7, any.template-haskell ==2.18.0.0, any.terminfo ==0.4.1.5, any.text ==1.2.5.0, any.text-short ==0.1.5, - any.th-abstraction ==0.4.5.0, - any.these ==1.1.1.1, + any.th-abstraction ==0.5.0.0, + any.these ==1.2, any.time ==1.11.1.1, any.time-compat ==1.9.6.1, any.transformers ==0.5.6.2, any.transformers-compat ==0.7.2, any.unix ==2.7.2.2, - any.unliftio-core ==0.2.0.1, + any.unliftio-core ==0.2.1.0, any.unordered-containers ==0.2.19.1, any.uuid-types ==1.0.5, any.vector ==0.12.3.1, any.vector-algorithms ==0.9.0.1, any.witherable ==0.4.2, - any.yaml ==0.11.8.0, + any.yaml ==0.11.11.2, any.zlib ==0.6.3.0 From 0f50924e36c89c95ad1e337e7874db1b2b68e7f0 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 19:54:49 +0200 Subject: [PATCH 05/13] Experiment with proteaaudio --- cabal.project.freeze | 1 + default.nix | 23 ++++++++++++++------ src/PlaySound.hs | 50 +++++++------------------------------------- text2speech.yaml | 6 +++--- tttool.cabal | 1 + 5 files changed, 29 insertions(+), 52 deletions(-) diff --git a/cabal.project.freeze b/cabal.project.freeze index fcf926f9..2e538356 100644 --- a/cabal.project.freeze +++ b/cabal.project.freeze @@ -57,6 +57,7 @@ constraints: any.HPDF ==1.4.10, any.pretty ==1.1.3.6, any.primitive ==0.8.0.0, any.process ==1.6.16.0, + any.proteaaudio ==0.9.4, any.random ==1.1, any.resourcet ==1.3.0, any.rts ==1.0.2, diff --git a/default.nix b/default.nix index b93fa0a1..da97882c 100644 --- a/default.nix +++ b/default.nix @@ -3,13 +3,20 @@ let sources = import nix/sources.nix; # Fetch the latest haskell.nix and import its default.nix - haskellNix = import sources.haskellNix {}; + haskellNix = import sources.haskellNix { + }; # Peek at https://github.com/input-output-hk/haskell.nix/blob/master/ci.nix # for supported nixpkgs and ghc versions # or https://github.com/input-output-hk/haskell.nix/blob/master/docs/reference/supported-ghc-versions.md nixpkgsSrc = haskellNix.sources.nixpkgs-unstable; - nixpkgsArgs = haskellNix.nixpkgsArgs; + nixpkgsArgs = haskellNix.nixpkgsArgs // { + overlays = haskellNix.nixpkgsArgs.overlays ++ [ + (self: super: { + pulse = super.libpulseaudio; # for haskell.nix + }) + ]; + }; pkgs = import nixpkgsSrc nixpkgsArgs; pkgs-osx = import nixpkgsSrc (nixpkgsArgs // { system = "x86_64-darwin"; }); @@ -55,7 +62,11 @@ let (tttool-project pkgs sha256).tttool.components.exes.tttool; tttool-shell = pkgs: sha256: (tttool-project pkgs sha256).shellFor { - buildInputs = [ pkgs.ghcid ]; + buildInputs = with pkgs; [ + ghcid + picotts + vorbis-tools + ]; }; @@ -83,13 +94,13 @@ let in rec { shell = tttool-shell pkgs - "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; + "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; linux-exe = tttool-exe pkgs - "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; + "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; windows-exe = tttool-exe pkgs.pkgsCross.mingwW64 "1x16mjjx4wnzksmpi4jg6ykvfvdshrhp58gciy9lfslavy9clf3a"; static-exe = tttool-exe pkgs.pkgsCross.musl64 - "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; + "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; osx-exe = tttool-exe pkgs-osx "sha256-hy8KuisPm/9FWDHPsV5IGFCWl7+VAjezT1DBH0wE1Yk="; osx-exe-bundle = osx-bundler pkgs-osx osx-exe; diff --git a/src/PlaySound.hs b/src/PlaySound.hs index 9644d245..aa9ea8bb 100644 --- a/src/PlaySound.hs +++ b/src/PlaySound.hs @@ -1,50 +1,14 @@ module PlaySound (playSound) where -import System.Process -import System.Exit -import Control.Monad -import Control.Exception -import System.IO.Error -import System.IO -import System.Directory -import System.FilePath import qualified Data.ByteString.Lazy as B -import System.Environment.Executable - -players :: FilePath -> FilePath -> [(FilePath, [String])] -players myDir fn = - [ ("sox", ["-q", fn, "-d"]) - , (myDir "contrib" "playmus", [fn]) - ] +import Sound.ProteaAudio playSound :: B.ByteString -> IO () playSound content = do - dir <- getTemporaryDirectory - (tmp, h) <- openTempFile dir "tttool-audio.tmp" - B.hPutStr h content - hClose h - - (myDir,_) <- splitExecutablePath - - tryPrograms (players myDir tmp) $ do - putStrLn "Could not play audio file." - putStrLn "Do you have \"sox\" installed?" - - removeFile tmp - -tryPrograms [] e = e -tryPrograms ((c,args):es) e = do - -- Missing programs cause exceptions on Windows, but error 127 on Linux. - -- Try to handle both here. - r <- tryJust (guard . isDoesNotExistError) $ do - ph <- runProcess c args Nothing Nothing Nothing Nothing Nothing - ret <- waitForProcess ph - if ret == ExitSuccess then return True - else if ret == ExitFailure 127 then return False - else do - putStrLn $ "Failed to execute \"" ++ c ++ "\" (" ++ show ret ++ ")" - exitFailure - case r of - Right True -> return () - _ -> tryPrograms es e + _ok <- initAudio 1 22050 512 + soundStopAll + sample <- sampleFromMemoryOgg (B.toStrict content) 1 + _sound <- soundPlay sample 1 1 0 1 + -- finishAudio + return () diff --git a/text2speech.yaml b/text2speech.yaml index afa9c42a..2ddc013e 100644 --- a/text2speech.yaml +++ b/text2speech.yaml @@ -7,9 +7,9 @@ welcome: hello language: en scripts: 8066: - - $mode==1? P(mode_one) - - $mode==2? P(mode_two) - - $mode==3? P(mode_three) + - $mode==0? P(mode_one) $mode := 1 + - $mode==1? P(mode_two) $mode := 2 + - $mode==2? P(mode_three) $mode := 0 # But instead of manually creating files hello.ogg, mode_one.ogg and # mode_two.ogg, you can specify text to be spoken for them. diff --git a/tttool.cabal b/tttool.cabal index 5041687a..c6696ca2 100644 --- a/tttool.cabal +++ b/tttool.cabal @@ -70,6 +70,7 @@ executable tttool build-depends: vector >= 0.10 && < 0.13 build-depends: yaml >= 0.8 && < 0.12 build-depends: zlib >= 0.5 && < 0.7 + build-depends: proteaaudio ^>= 0.9.4 hs-source-dirs: src default-language: GHC2021 From 6a0867de55f334aca2ec314956221871af36522f Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 20:10:33 +0200 Subject: [PATCH 06/13] Fix OSX hash --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index da97882c..a0b5b94b 100644 --- a/default.nix +++ b/default.nix @@ -102,7 +102,7 @@ in rec { static-exe = tttool-exe pkgs.pkgsCross.musl64 "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; osx-exe = tttool-exe pkgs-osx - "sha256-hy8KuisPm/9FWDHPsV5IGFCWl7+VAjezT1DBH0wE1Yk="; + "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; osx-exe-bundle = osx-bundler pkgs-osx osx-exe; static-files = sourceByRegex ./. [ From b0fe89be2d93cf51a3145e68f2bc61391c27bd39 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 14 Jul 2023 20:13:37 +0200 Subject: [PATCH 07/13] Update windows Hash --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index a0b5b94b..ef83b934 100644 --- a/default.nix +++ b/default.nix @@ -98,11 +98,11 @@ in rec { linux-exe = tttool-exe pkgs "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; windows-exe = tttool-exe pkgs.pkgsCross.mingwW64 - "1x16mjjx4wnzksmpi4jg6ykvfvdshrhp58gciy9lfslavy9clf3a"; + "0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz"; static-exe = tttool-exe pkgs.pkgsCross.musl64 "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; osx-exe = tttool-exe pkgs-osx - "12fm0i61zhah9yrkf0lmpybrcl0q91gb3krib12zz6qg5fx0lbw7"; + "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; osx-exe-bundle = osx-bundler pkgs-osx osx-exe; static-files = sourceByRegex ./. [ From ea9005dbbf6b4c099d2cc3873b373cb661268155 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 15 Jul 2023 19:27:20 +0200 Subject: [PATCH 08/13] Windows support --- default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index ef83b934..8792ec87 100644 --- a/default.nix +++ b/default.nix @@ -13,7 +13,9 @@ let nixpkgsArgs = haskellNix.nixpkgsArgs // { overlays = haskellNix.nixpkgsArgs.overlays ++ [ (self: super: { - pulse = super.libpulseaudio; # for haskell.nix + # these help haskell.nix to resolve system library dependencies + dsound = null; + pulse = super.libpulseaudio; }) ]; }; From 8752cd361afc69046691d381a64acb80670bd108 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 15 Jul 2023 23:07:42 +0200 Subject: [PATCH 09/13] Work around cross building kmod issues see https://github.com/input-output-hk/haskell.nix/issues/2002 --- default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/default.nix b/default.nix index 8792ec87..6f06728f 100644 --- a/default.nix +++ b/default.nix @@ -16,6 +16,8 @@ let # these help haskell.nix to resolve system library dependencies dsound = null; pulse = super.libpulseaudio; + # to work around https://github.com/input-output-hk/haskell.nix/issues/2002 + kmod = super.kmod.override { xz = self.xz.override { enableStatic = false;};}; }) ]; }; From da7904852fc5afc78d7cf02d05858dd18398612f Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Thu, 20 Jul 2023 19:06:49 +0200 Subject: [PATCH 10/13] With mkForce it works! --- default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/default.nix b/default.nix index 6f06728f..487dfc3e 100644 --- a/default.nix +++ b/default.nix @@ -53,6 +53,9 @@ let modules = [{ # smaller files packages.tttool.dontStrip = false; + packages.proteaaudio.components.library.build-tools = pkgs.lib.mkForce [ + pkgs.buildPackages.haskellPackages.c2hs + ]; }] ++ pkgs.lib.optional pkgs.hostPlatform.isMusl { packages.tttool.configureFlags = [ "--ghc-option=-static" ]; From 62ba161c069ffb81214cd297c74a8a995e01ee02 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 22 Jul 2023 18:19:46 +0200 Subject: [PATCH 11/13] Test MP3 supprot https://github.com/csabahruska/proteaaudio/issues/12 --- cabal.project | 7 +++++++ cabal.project.freeze | 2 +- default.nix | 8 ++++---- src/PlaySound.hs | 16 ++++++++++++++-- tttool.cabal | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/cabal.project b/cabal.project index 90be9908..d5b996c8 100644 --- a/cabal.project +++ b/cabal.project @@ -8,3 +8,10 @@ source-repository-package location: https://github.com/nomeata/HPDF tag: a43e6dd41e8d4e967f1fe9f6e30286a8a9dead64 --sha256: 1s23rnwln40jxr0vnlr0r74sjysrj4s14brvr3nhb7q1y4yb5366 + +source-repository-package + type: git + location: https://github.com/csabahruska/proteaaudio + tag: 7a22a2e9dcff5b3ce989d353aa4cb1ac4b676d09 + subdir: proteaaudio + --sha256: 1n4z69ds5yn0dsnwczpcrhba3c2k1l6v0xnwz6s05kc2kd7a58zi diff --git a/cabal.project.freeze b/cabal.project.freeze index 2e538356..9805a244 100644 --- a/cabal.project.freeze +++ b/cabal.project.freeze @@ -57,7 +57,7 @@ constraints: any.HPDF ==1.4.10, any.pretty ==1.1.3.6, any.primitive ==0.8.0.0, any.process ==1.6.16.0, - any.proteaaudio ==0.9.4, + any.proteaaudio ==1.0.0, any.random ==1.1, any.resourcet ==1.3.0, any.rts ==1.0.2, diff --git a/default.nix b/default.nix index 487dfc3e..036ae437 100644 --- a/default.nix +++ b/default.nix @@ -101,15 +101,15 @@ let in rec { shell = tttool-shell pkgs - "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; + "1x9v6vgycidmjaapxfvc6zn3zwawahh9ly3kx8sp0w42j3h8d50d"; linux-exe = tttool-exe pkgs - "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; + "1x9v6vgycidmjaapxfvc6zn3zwawahh9ly3kx8sp0w42j3h8d50d"; windows-exe = tttool-exe pkgs.pkgsCross.mingwW64 "0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz"; static-exe = tttool-exe pkgs.pkgsCross.musl64 - "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; + "1x9v6vgycidmjaapxfvc6zn3zwawahh9ly3kx8sp0w42j3h8d50d"; osx-exe = tttool-exe pkgs-osx - "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb"; + "1x9v6vgycidmjaapxfvc6zn3zwawahh9ly3kx8sp0w42j3h8d50d"; osx-exe-bundle = osx-bundler pkgs-osx osx-exe; static-files = sourceByRegex ./. [ diff --git a/src/PlaySound.hs b/src/PlaySound.hs index aa9ea8bb..36a92f11 100644 --- a/src/PlaySound.hs +++ b/src/PlaySound.hs @@ -1,14 +1,26 @@ module PlaySound (playSound) where -import qualified Data.ByteString.Lazy as B +import qualified Data.ByteString.Lazy.Char8 as B import Sound.ProteaAudio + +sampleFromMemory :: B.ByteString -> Float -> IO Sample +sampleFromMemory bs + | B.take 4 bs == B.pack "RIFF" = sampleFromMemoryWav (B.toStrict bs) + | B.take 4 bs == B.pack "OggS" = sampleFromMemoryOgg (B.toStrict bs) + | B.take 3 bs == B.pack "ID3" || B.take 2 bs `elem` + [B.pack "\xFF\xFB", B.pack "\xFF\xF3", B.pack "\xFF\xF2"] + = sampleFromMemoryMp3 (B.toStrict bs) + | otherwise = error "Could not detect audio format" + where magic = B.take 4 bs + + playSound :: B.ByteString -> IO () playSound content = do _ok <- initAudio 1 22050 512 soundStopAll - sample <- sampleFromMemoryOgg (B.toStrict content) 1 + sample <- sampleFromMemory content 1 _sound <- soundPlay sample 1 1 0 1 -- finishAudio return () diff --git a/tttool.cabal b/tttool.cabal index c6696ca2..77192492 100644 --- a/tttool.cabal +++ b/tttool.cabal @@ -70,7 +70,7 @@ executable tttool build-depends: vector >= 0.10 && < 0.13 build-depends: yaml >= 0.8 && < 0.12 build-depends: zlib >= 0.5 && < 0.7 - build-depends: proteaaudio ^>= 0.9.4 + build-depends: proteaaudio ^>= 1.0 hs-source-dirs: src default-language: GHC2021 From 983a682337ddb0672b225b12b25561c9b976053d Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 22 Jul 2023 18:25:49 +0200 Subject: [PATCH 12/13] Update windows plan --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 036ae437..b745a412 100644 --- a/default.nix +++ b/default.nix @@ -105,7 +105,7 @@ in rec { linux-exe = tttool-exe pkgs "1x9v6vgycidmjaapxfvc6zn3zwawahh9ly3kx8sp0w42j3h8d50d"; windows-exe = tttool-exe pkgs.pkgsCross.mingwW64 - "0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz"; + "0b7kka4105rh0fagx25a9plangdpvh1ca7r2kfyiq6kya7hnlgz3"; static-exe = tttool-exe pkgs.pkgsCross.musl64 "1x9v6vgycidmjaapxfvc6zn3zwawahh9ly3kx8sp0w42j3h8d50d"; osx-exe = tttool-exe pkgs-osx From 5037aae76cf215939f2ba263bbc4d99bcb5edef3 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Thu, 31 Aug 2023 18:05:47 +0200 Subject: [PATCH 13/13] Do not mention scripts/update.sh --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 97ee49f8..6559058c 100644 --- a/README.md +++ b/README.md @@ -142,9 +142,6 @@ Other resources in this repository ---------------------------------- * [`oid-decoder.html`](http://htmlpreview.github.io/?https://github.com/entropia/tip-toi-reveng/blob/master/oid-decoder.html) allows you to manually decode an OID image. - * `scripts/update.sh` downloads all gme files from the Ravensburger server (requires perl and the [XML::Simple](http://search.cpan.org/~grantm/XML-Simple/) module). - - Instead of downloading all of them, you can conveniently browse them at , a service provided by Falko Oldenburg . * `gameanalyse.c` and `libtiptoi.c` is an alternative tool to investigate gme files. It can also [replace audio files in gme files](Audio/README.md); compile and run it for diagnostic output.