tidalcycles / Tidal

Pattern language
http://tidalcycles.org/
GNU General Public License v3.0
2.27k stars 255 forks source link

Another failing case with cabal #706

Closed jcguu95 closed 4 years ago

jcguu95 commented 4 years ago

Is there a minimal way to get everything working without an IDE? I keep getting sound: variable not in scope with emacs, but none of the issues seem to help..

bgold-cosmos commented 4 years ago

Yes, the minimal method from the command line is to start up ghci and source the BootTidal.hs script:

bgold% ghci
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Prelude> :s Your/Path/To/BootTidal.hs
Listening for controls on 127.0.0.1:6010
tidal>

the tricky part might be figuring out where the BootTidal.hs script is. Both the atom tidalcycles package and cabal will put it somewhere, but it might be a bit of work to find it.

If you really can't find a BootTidal.hs, then I think a very minimal set of commands to start things up in GHCi would be

:set -XOverloadedStrings
import Sound.Tidal.Context
tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cFrameTimespan = 1/20})
p = streamReplace tidal
d1 = p 1 . (|< orbit 0)
jcguu95 commented 4 years ago

Exciting! Should evaluating d1 now generates a sound, provided that my SuperCollider and SuperDirt are well installed?

jwaldmann commented 4 years ago

Yes d1 $ s "bd" should work - after Supercollider is started (I type sclang in a shell for that, there are graphical methods as well)

bgold-cosmos commented 4 years ago

You can set up other d2,d3, etc with dx = p x . (|< orbit x) if you like, the full BootTidal.hs (https://github.com/tidalcycles/Tidal/blob/main/BootTidal.hs) contains a bunch of stuff but it's possible to just copy/paste what you need.

jwaldmann commented 4 years ago

how to locate the boot script: one drastic method is

find .cabal -name "BootTidal.hs"

it will print something like

.cabal/store/ghc-8.10.2/tidal-1.6.1-9f60dd09c4e084d09a35f417ee739018445a74d28aa93f87d47e6d5e4232f237/share/BootTidal.hs

for me, after I installed with cabal install tidal --lib. This is with cabal-install version 3.2.0.0.

jcguu95 commented 4 years ago

Found!

> $ cd .cabal
> $ find . -name "BootTidal.hs"
./store/ghc-8.8.3/tidal-1.6.1-3bfa193782f4cc8c5b909f6c497b31d68d8f362723f25a181f0586c5b8deaa85/share/BootTidal.hs

I'm still trying to figure out how (and what it means) to setup JACK, and get SuperDirt well installed. Cannot wait!

jwaldmann commented 4 years ago

"setup jack" is easiest if you can use your distribution's packages and their configuration methods.

E.g., for Fedora, jack-audio-connection-kit and pulseaudio-module-jack (yes, you have to fight pulseaudio which is the default on some systems). Or install some other audio application that will pull in jack (and supporting tools) as a dependency, like ardour5-audiobackend-jack (I guess).

"Superdirt": thats another different topic. See their documentation https://github.com/musikinformatik/SuperDirt#installation-from-supercollider

jcguu95 commented 4 years ago

It werked.......................................................! Thank you <3

Related

jcguu95 commented 4 years ago

@jwaldmann your methods worked perfectly. I even reproduced that in emacs!

This makes me wonder however that why didn't emacs tidal-mode take care of this..

jwaldmann commented 4 years ago

It does. It is using

ghc-pkg field -f ~/.cabal/store/ghc-$(ghc --numeric-version)/package.db tidal data-dir

to find the location (directory) of the boot file. It should print the same as the find command (actually, a subset, for the specified ghc).

[EDIT] after re-checking: it did, but the current version does not? This was discussed in a separate issue #615 (I did not follow this.)

jcguu95 commented 4 years ago

Running that in terminal outputs

ghc-pkg: /home/me/.cabal/store/ghc-8.8.3/package.db/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not enough bytes)

Should I change data-dir to anything else?


I installed tidal with cabal.. don't know how #615 relates :(

jwaldmann commented 4 years ago

GHC.PackageDb.readPackageDb

Hm. What does ghc-pkg --version say? It should match ghc --version.

Possibly related: https://github.com/haskell/cabal/issues/4287

jcguu95 commented 4 years ago

They are indeed different...

ghc-pkg --version # --> 8.10.1
ghc --version        # --> 8.8.3

$ which ghc
/home/me/.ghcup/ghc/8.8.3/bin/ghc
$ which ghc-pkg
/usr/bin/ghc-pkg

Removing system-wide ghc-pkg by sudo pacman -R ghc-libs solves this problem temporarily. I will come back if there's another problem.

EDIT SOLVED! Now emacs tidal-mode works as expected. Thank you so much!

jwaldmann commented 4 years ago

so you installed an old ghc (8.8) via ghcup while your distribution has a more recent one (8.10)? why not use that? and still build packages from source and install privately, with cabal?

Well, if your method works, it works ...

jcguu95 commented 4 years ago

I trust cabal new styles more than the community..

It really did work for one time, but stop working again after I turned it off and on. Though I think this should be mentioned in another thread.


This time opening a .tidal file in emacs brought me into tidal-mode directly. But C-c C-s didn't call BootTidal.hs correctly I guess, as it spits out the tidal buffer saying

GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/me/.ghc/x86_64-linux-8.8.3/environments/default
Prelude> syntax:  :script <filename>
Prelude> 

I had to type in

:set -XOverloadedStrings
import Sound.Tidal.Context
tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cFrameTimespan = 1/20})
p = streamReplace tidal
d1 = p 1 . (|< orbit 0)

manually to make it work.