为计算机音乐应用程序安装 Euterpea 和 Haskell
Installing Euterpea for computer music applications and Haskell
我按照此处 http://www.euterpea.com 的说明安装 Euterpea(一种嵌入 Haskell 的计算机音乐应用程序的特定领域语言),但我收到一条消息,提示某些包和东西无法安装(见下面的代码)。如何安装剩余的软件包?
Mo-MacBook-Pro:~ Mo$ cabal update
Downloading the latest package list from hackage.haskell.org
cabal install Euterpea
To revert to previous state run:
cabal update --index-state='2018-06-25T08:34:14Z'
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Resolving dependencies...
Downloading heap-1.0.4...
Downloading PortMidi-0.1.6.1...
Configuring PortMidi-0.1.6.1...
Downloading lazysmallcheck-0.6...
Configuring heap-1.0.4...
Downloading semigroups-0.18.5...
Configuring lazysmallcheck-0.6...
Configuring semigroups-0.18.5...
Building heap-1.0.4...
Building PortMidi-0.1.6.1...
Building lazysmallcheck-0.6...
Building semigroups-0.18.5...
Installed semigroups-0.18.5
Downloading stm-2.5.0.0...
Configuring stm-2.5.0.0...
Installed lazysmallcheck-0.6
Downloading HCodecs-0.5.1...
Installed heap-1.0.4
Downloading Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Configuring Stream-0.4.7.2...
Building stm-2.5.0.0...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1-
BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1-
7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2-
ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4,
14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3-
4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Installed PortMidi-0.1.6.1
Installed stm-2.5.0.0
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which
failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase.
The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase.
The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which
failed
to install.
如果有人能提供帮助就太好了。谢谢。
我已经包含了所有代码,以免遗漏一些特定的相关细节。
编辑
我也试过通过堆栈安装 Euterpea。我收到此消息:
Mo-MacBook-Pro:~ Mo$ stack install Euterpea
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for Euterpea-2.0.6:
PortMidi must match ==0.1.6.1, but the stack configuration has no specified version (latest matching version is 0.1.6.1)
arrows must match >=0.4 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.4.2)
needed since Euterpea is a build target.
Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps in /Users/Mo/.stack/global-project/stack.yaml:
- PortMidi-0.1.6.1
- arrows-0.4.4.2
Plan construction failed.
--
编辑 2.
按照下面的建议,我尝试了 cabal install random-1.1 --force-reinstalls
生成了:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
tf-random-0.5
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Configuring random-1.1...
Building random-1.1...
Installed random-1.1
然后
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Configuring Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/lukeburke/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1- BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1- 7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2- ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4, 14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3- 4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase. The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase. The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which failed
to install.
编辑 3
下面建议多个软件包被破坏,我应该尝试重新安装所有这些软件包(在一个命令中,即 cabal install random tf-random QuickCheck Euterpea --force-reinstalls
.
但是,如果我写 cabal install random tf-random QuickCheck Euterpea --force-reinstalls
,我会收到以下代码:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Downloading erf-2.0.0.0...
Configuring random-1.1...
Configuring erf-2.0.0.0...
Building random-1.1...
Building erf-2.0.0.0...
Installed erf-2.0.0.0
Installed random-1.1
Downloading tf-random-0.5...
Configuring tf-random-0.5...
Building tf-random-0.5...
Failed to install tf-random-0.5
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/tf-random-0.5- ADZoyzEXgHe6hyR0Bycce0.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
Configuring tf-random-0.5...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for tf-random-0.5..
Building library for tf-random-0.5..
<command line>: cannot satisfy -package-id primitive-0.6.4.0- 9k41Y6ToOAE8KXK6VMGV2O
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-87WYqltNL8w8teqXOsc4TL depends on Euterpea-2.0.6 which failed
to install.
HCodecs-0.5.1-DrGKEnNk6EBHti2goL6KP5 depends on HCodecs-0.5.1 which. failed to
install.
QuickCheck-2.12.6.1-KuXpgimNOXzF2SmGPEs5LR depends on QuickCheck- 2.12.6.1
which failed to install.
Stream-0.4.7.2-FedzVSwUnWMDxlzmPNWt7x depends on Stream-0.4.7.2 which failed
to install.
arrows-0.4.4.2-EGvZPpby4BcD99TcXDoCg4 depends on arrows-0.4.4.2 which. failed
to install.
tf-random-0.5-ADZoyzEXgHe6hyR0Bycce0 failed during the building phase. The
exception was:
ExitFailure 1
如何安装 Euterpea?
正在安装 Euterpea 软件包
这个答案使用 LTS 12.26,因为我已经验证它可以工作,但这应该适用于大多数 LTS 版本(详情请参阅步骤 2 的底部)。
创建一个新的 Stack 项目:
stack new euter-test
cd euter-test
编辑 stack.yaml
并将 LTS 设置为 12.26 和 extra-deps
以指定 LTS 中不存在但存在于 Hackage 中的软件包版本:
resolver: lts-12.26
...
extra-deps:
- Euterpea-2.0.6
- PortMidi-0.1.6.1
- arrows-0.4.4.2
- Stream-0.4.7.2
- lazysmallcheck-0.6
您在 Stack 安装 ("PortMidi must match ==0.1.6.1, but the stack configuration has no specified version") 中遇到的错误表明您正在使用的软件包需要特定版本的库,但软件包存储库(LTS 快照)不包含该版本库,因此您需要明确指定它。然后 Stack 打印缺少哪个库和版本,因此您可以继续尝试 stack build
并添加库,直到构建成功。
我们在这里使用 LTS 12.26,但是通过如上所述添加 extra-deps
包,您应该能够让它在任何 LTS 上运行。
编辑 package.yaml
并将 Euterpea
添加到依赖项列表:
dependencies:
...
- Euterpea
app/Main.hs
中的简单测试:
module Main where
import Euterpea
main :: IO ()
main = play $ c 4 qn
运行 stack build
:
lazysmallcheck-0.6: download
heap-1.0.4: download
heap-1.0.4: configure
HCodecs-0.5.1: download
PortMidi-0.1.6.1: download
heap-1.0.4: build
lazysmallcheck-0.6: configure
lazysmallcheck-0.6: build
HCodecs-0.5.1: configure
HCodecs-0.5.1: build
PortMidi-0.1.6.1: configure
heap-1.0.4: copy/register
lazysmallcheck-0.6: copy/register
PortMidi-0.1.6.1: build
Stream-0.4.7.2: download
Stream-0.4.7.2: configure
Stream-0.4.7.2: build
Stream-0.4.7.2: copy/register
PortMidi-0.1.6.1: copy/register
arrows-0.4.4.2: download
arrows-0.4.4.2: configure
arrows-0.4.4.2: build
arrows-0.4.4.2: copy/register
HCodecs-0.5.1: copy/register
Euterpea-2.0.6: download
Euterpea-2.0.6: configure
Euterpea-2.0.6: build
Euterpea-2.0.6: copy/register
Building all executables for `euter' once. After a successful build of all of them, only specified executables will be rebuilt.
euter-0.1.0.0: configure (lib + exe)
Configuring euter-0.1.0.0...
euter-0.1.0.0: build (lib + exe)
Preprocessing library for euter-0.1.0.0..
Building library for euter-0.1.0.0..
[1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Lib.o )
[2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Paths_euter.o )
Preprocessing executable 'euter-exe' for euter-0.1.0.0..
Building executable 'euter-exe' for euter-0.1.0.0..
[1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Main.o )
[2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Paths_euter.o )
Linking .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe ...
euter-0.1.0.0: copy/register
Installing library in <...>
Installing executable euter-exe in <...>
Registering library for euter-0.1.0.0..
运行如果您运行正在使用 MIDI 合成器,则项目生成的可执行文件应该会发出声音:
stack exec euter-test-exe
疑难解答
如果您遇到类似 *** Exception: No MIDI outputs!
的错误,则您没有 运行 MIDI 合成器(见下文)。确保你 运行 它在后台(例如在另一个终端)。
如果没有报错但是没有音频输出,试试在GHCI中运行ning devices
看看有哪些输出可用,然后用playDev x
而不是 play
,其中 x
是合成器输入端口的 OutputDeviceID。例如:
> devices
Input devices:
InputDeviceID 1 Midi Through Port-0
Output devices:
OutputDeviceID 0 Midi Through Port-0
OutputDeviceID 2 Synth input port (25952:0)
> playDev 2 $ c 4 qn
如果你 运行 devices
没有看到任何合成器输入端口,但你有 fluidsynth 运行ning 在后台,那么你可能需要重新启动 ghci
并重试。
运行安装 MIDI 合成器
这是在 Debian 上获取 Fluidsynth 运行ning 的快速分步说明(在此过程中猜测 Mac 设置)。
安装 fluidsynth:
在 Debian 上,这是 sudo apt install fluidsynth
,在 mac 上,它可能是 brew install fluidsynth
- 有很多文章介绍如何做到这一点,如果有疑问,只需 google 即可。
运行 流体合成器:
在使用 ALSA 的 Debian 上,这是
fluidsynth -s -a alsa -m alsa_seq /usr/share/sounds/sf2/FluidR3_GM.sf2
在服务器模式下指示 fluidsynth 运行,使用 alsa
作为音频驱动程序,使用 alsa_seq
作为 MIDI 驱动程序,并使用 soundfont FluidR3_GM.sf2
(应该是作为 fluidsynth 安装的一部分安装)。
在 Mac 上,正确的命令行似乎是:
fluidsynth -s -a coreaudio -m coremidi /usr/share/sounds/sf2/FluidR3_GM.sf2
如果您找不到 FluidR3_GM.sf2
文件,则它可能已安装在其他位置。作为最后的手段,您可以只下载一个 soundfont 文件并使用它,而不是 FluidSynth 提供的文件。
在此 运行ning 之后,您应该会得到一个提示,也许还有一些警告,而 fluidsynth 将 运行ning。在使用 Euterpea 之前确保它是 运行ning,并在使用 Euterpea 时保持它 运行ning。
我按照此处 http://www.euterpea.com 的说明安装 Euterpea(一种嵌入 Haskell 的计算机音乐应用程序的特定领域语言),但我收到一条消息,提示某些包和东西无法安装(见下面的代码)。如何安装剩余的软件包?
Mo-MacBook-Pro:~ Mo$ cabal update
Downloading the latest package list from hackage.haskell.org
cabal install Euterpea
To revert to previous state run:
cabal update --index-state='2018-06-25T08:34:14Z'
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Resolving dependencies...
Downloading heap-1.0.4...
Downloading PortMidi-0.1.6.1...
Configuring PortMidi-0.1.6.1...
Downloading lazysmallcheck-0.6...
Configuring heap-1.0.4...
Downloading semigroups-0.18.5...
Configuring lazysmallcheck-0.6...
Configuring semigroups-0.18.5...
Building heap-1.0.4...
Building PortMidi-0.1.6.1...
Building lazysmallcheck-0.6...
Building semigroups-0.18.5...
Installed semigroups-0.18.5
Downloading stm-2.5.0.0...
Configuring stm-2.5.0.0...
Installed lazysmallcheck-0.6
Downloading HCodecs-0.5.1...
Installed heap-1.0.4
Downloading Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Configuring Stream-0.4.7.2...
Building stm-2.5.0.0...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1-
BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1-
7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2-
ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4,
14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3-
4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Installed PortMidi-0.1.6.1
Installed stm-2.5.0.0
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which
failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase.
The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase.
The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which
failed
to install.
如果有人能提供帮助就太好了。谢谢。
我已经包含了所有代码,以免遗漏一些特定的相关细节。
编辑
我也试过通过堆栈安装 Euterpea。我收到此消息:
Mo-MacBook-Pro:~ Mo$ stack install Euterpea
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for Euterpea-2.0.6:
PortMidi must match ==0.1.6.1, but the stack configuration has no specified version (latest matching version is 0.1.6.1)
arrows must match >=0.4 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.4.2)
needed since Euterpea is a build target.
Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps in /Users/Mo/.stack/global-project/stack.yaml:
- PortMidi-0.1.6.1
- arrows-0.4.4.2
Plan construction failed.
-- 编辑 2.
按照下面的建议,我尝试了 cabal install random-1.1 --force-reinstalls
生成了:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
tf-random-0.5
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Configuring random-1.1...
Building random-1.1...
Installed random-1.1
然后
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Configuring Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/lukeburke/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1- BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1- 7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2- ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4, 14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3- 4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase. The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase. The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which failed
to install.
编辑 3
下面建议多个软件包被破坏,我应该尝试重新安装所有这些软件包(在一个命令中,即 cabal install random tf-random QuickCheck Euterpea --force-reinstalls
.
但是,如果我写 cabal install random tf-random QuickCheck Euterpea --force-reinstalls
,我会收到以下代码:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Downloading erf-2.0.0.0...
Configuring random-1.1...
Configuring erf-2.0.0.0...
Building random-1.1...
Building erf-2.0.0.0...
Installed erf-2.0.0.0
Installed random-1.1
Downloading tf-random-0.5...
Configuring tf-random-0.5...
Building tf-random-0.5...
Failed to install tf-random-0.5
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/tf-random-0.5- ADZoyzEXgHe6hyR0Bycce0.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
Configuring tf-random-0.5...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for tf-random-0.5..
Building library for tf-random-0.5..
<command line>: cannot satisfy -package-id primitive-0.6.4.0- 9k41Y6ToOAE8KXK6VMGV2O
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-87WYqltNL8w8teqXOsc4TL depends on Euterpea-2.0.6 which failed
to install.
HCodecs-0.5.1-DrGKEnNk6EBHti2goL6KP5 depends on HCodecs-0.5.1 which. failed to
install.
QuickCheck-2.12.6.1-KuXpgimNOXzF2SmGPEs5LR depends on QuickCheck- 2.12.6.1
which failed to install.
Stream-0.4.7.2-FedzVSwUnWMDxlzmPNWt7x depends on Stream-0.4.7.2 which failed
to install.
arrows-0.4.4.2-EGvZPpby4BcD99TcXDoCg4 depends on arrows-0.4.4.2 which. failed
to install.
tf-random-0.5-ADZoyzEXgHe6hyR0Bycce0 failed during the building phase. The
exception was:
ExitFailure 1
如何安装 Euterpea?
正在安装 Euterpea 软件包
这个答案使用 LTS 12.26,因为我已经验证它可以工作,但这应该适用于大多数 LTS 版本(详情请参阅步骤 2 的底部)。
创建一个新的 Stack 项目:
stack new euter-test cd euter-test
编辑
stack.yaml
并将 LTS 设置为 12.26 和extra-deps
以指定 LTS 中不存在但存在于 Hackage 中的软件包版本:resolver: lts-12.26 ... extra-deps: - Euterpea-2.0.6 - PortMidi-0.1.6.1 - arrows-0.4.4.2 - Stream-0.4.7.2 - lazysmallcheck-0.6
您在 Stack 安装 ("PortMidi must match ==0.1.6.1, but the stack configuration has no specified version") 中遇到的错误表明您正在使用的软件包需要特定版本的库,但软件包存储库(LTS 快照)不包含该版本库,因此您需要明确指定它。然后 Stack 打印缺少哪个库和版本,因此您可以继续尝试
stack build
并添加库,直到构建成功。我们在这里使用 LTS 12.26,但是通过如上所述添加
extra-deps
包,您应该能够让它在任何 LTS 上运行。编辑
package.yaml
并将Euterpea
添加到依赖项列表:dependencies: ... - Euterpea
app/Main.hs
中的简单测试:module Main where import Euterpea main :: IO () main = play $ c 4 qn
运行
stack build
:lazysmallcheck-0.6: download heap-1.0.4: download heap-1.0.4: configure HCodecs-0.5.1: download PortMidi-0.1.6.1: download heap-1.0.4: build lazysmallcheck-0.6: configure lazysmallcheck-0.6: build HCodecs-0.5.1: configure HCodecs-0.5.1: build PortMidi-0.1.6.1: configure heap-1.0.4: copy/register lazysmallcheck-0.6: copy/register PortMidi-0.1.6.1: build Stream-0.4.7.2: download Stream-0.4.7.2: configure Stream-0.4.7.2: build Stream-0.4.7.2: copy/register PortMidi-0.1.6.1: copy/register arrows-0.4.4.2: download arrows-0.4.4.2: configure arrows-0.4.4.2: build arrows-0.4.4.2: copy/register HCodecs-0.5.1: copy/register Euterpea-2.0.6: download Euterpea-2.0.6: configure Euterpea-2.0.6: build Euterpea-2.0.6: copy/register Building all executables for `euter' once. After a successful build of all of them, only specified executables will be rebuilt. euter-0.1.0.0: configure (lib + exe) Configuring euter-0.1.0.0... euter-0.1.0.0: build (lib + exe) Preprocessing library for euter-0.1.0.0.. Building library for euter-0.1.0.0.. [1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Lib.o ) [2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Paths_euter.o ) Preprocessing executable 'euter-exe' for euter-0.1.0.0.. Building executable 'euter-exe' for euter-0.1.0.0.. [1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Main.o ) [2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Paths_euter.o ) Linking .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe ... euter-0.1.0.0: copy/register Installing library in <...> Installing executable euter-exe in <...> Registering library for euter-0.1.0.0..
运行如果您运行正在使用 MIDI 合成器,则项目生成的可执行文件应该会发出声音:
stack exec euter-test-exe
疑难解答
如果您遇到类似
*** Exception: No MIDI outputs!
的错误,则您没有 运行 MIDI 合成器(见下文)。确保你 运行 它在后台(例如在另一个终端)。如果没有报错但是没有音频输出,试试在GHCI中运行ning
devices
看看有哪些输出可用,然后用playDev x
而不是play
,其中x
是合成器输入端口的 OutputDeviceID。例如:> devices Input devices: InputDeviceID 1 Midi Through Port-0 Output devices: OutputDeviceID 0 Midi Through Port-0 OutputDeviceID 2 Synth input port (25952:0) > playDev 2 $ c 4 qn
如果你 运行
devices
没有看到任何合成器输入端口,但你有 fluidsynth 运行ning 在后台,那么你可能需要重新启动ghci
并重试。
运行安装 MIDI 合成器
这是在 Debian 上获取 Fluidsynth 运行ning 的快速分步说明(在此过程中猜测 Mac 设置)。
安装 fluidsynth: 在 Debian 上,这是
sudo apt install fluidsynth
,在 mac 上,它可能是brew install fluidsynth
- 有很多文章介绍如何做到这一点,如果有疑问,只需 google 即可。运行 流体合成器: 在使用 ALSA 的 Debian 上,这是
fluidsynth -s -a alsa -m alsa_seq /usr/share/sounds/sf2/FluidR3_GM.sf2
在服务器模式下指示 fluidsynth 运行,使用
alsa
作为音频驱动程序,使用alsa_seq
作为 MIDI 驱动程序,并使用 soundfontFluidR3_GM.sf2
(应该是作为 fluidsynth 安装的一部分安装)。在 Mac 上,正确的命令行似乎是:
fluidsynth -s -a coreaudio -m coremidi /usr/share/sounds/sf2/FluidR3_GM.sf2
如果您找不到
FluidR3_GM.sf2
文件,则它可能已安装在其他位置。作为最后的手段,您可以只下载一个 soundfont 文件并使用它,而不是 FluidSynth 提供的文件。在此 运行ning 之后,您应该会得到一个提示,也许还有一些警告,而 fluidsynth 将 运行ning。在使用 Euterpea 之前确保它是 运行ning,并在使用 Euterpea 时保持它 运行ning。