haskell-game / sdl2-mixer Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tempname11/sdl2-mixer
Haskell bindings to SDL2_mixer.
License: BSD 3-Clause "New" or "Revised" License
This project forked from tempname11/sdl2-mixer
Haskell bindings to SDL2_mixer.
License: BSD 3-Clause "New" or "Revised" License
The hackage server doesn't have SDL2_mixer installed:
https://hackage.haskell.org/package/sdl2-mixer-1.1.0/reports/2
> /tmp/stackage-build13$ stack unpack sdl2-mixer-0.1
Unpacked sdl2-mixer-0.1 to /tmp/stackage-build13/sdl2-mixer-0.1/
> /tmp/stackage-build13/sdl2-mixer-0.1$ ghc -clear-package-db -global-package-db -package-db=/var/stackage/work/builds/nightly/pkgdb Setup
[1 of 1] Compiling Main ( Setup.hs, Setup.o )
Linking Setup ...
> /tmp/stackage-build13/sdl2-mixer-0.1$ ./Setup configure --package-db=clear --package-db=global --package-db=/var/stackage/work/builds/nightly/pkgdb --libdir=/var/stackage/work/builds/nightly/lib --bindir=/var/stackage/work/builds/nightly/bin --datadir=/var/stackage/work/builds/nightly/share --libexecdir=/var/stackage/work/builds/nightly/libexec --sysconfdir=/var/stackage/work/builds/nightly/etc --docdir=/var/stackage/work/builds/nightly/doc/sdl2-mixer-0.1 --htmldir=/var/stackage/work/builds/nightly/doc/sdl2-mixer-0.1 --haddockdir=/var/stackage/work/builds/nightly/doc/sdl2-mixer-0.1 --flags=
Configuring sdl2-mixer-0.1...
Setup: The pkg-config package 'SDL2_mixer' version >=2.0.0 is required but it
could not be found.
When I try to run it in cabal repl, it is unable to resolve depencies:
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: fake-package-0 (user goal)
[__1] next goal: sdl2-mixer (dependency of fake-package)
[__1] rejecting: sdl2-mixer-1.1.0, sdl2-mixer-0.1 (conflict: pkg-config
package SDL2_mixer==2.0.0 || >2.0.0, not found in the pkg-config database)
[__1] fail (backjumping, conflict set: fake-package, sdl2-mixer)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: sdl2-mixer, fake-package```
sorry for the generic title.
I just finished debugging an issue where I used load
to read a music file from disk and play it.
I also kept all the Music
values I loaded in a Map.
I ran into all kinds of strange bugs, music jumping forward at a specific place,
trying to play music I already played wouldn't do anything after playing something else, music starting from the middle of the file, etc.
Then I thought that maybe the ByteString
content of the file was garbage collected and/or overwritten or something. So instead of keeping a Map of Music
I kept a Map of ByteString
which is the result of readFile
and I played music using playMusic Forever <=< decode
. This fixed the issues I had.
Am I correct in my assumptions? Maybe the load
API is problematic and should be removed?
I just wanted to share this so it might help others if they trip on these kind of bugs.
Thanks!
Hi ! It's been a few days and I've struggled with this bug as it seemed totally random. Basically I'm using the library to play a whole song, and short samples. Here is the code:
fileOn :: String -> Mix.Channel -> IO ThreadId
fileOn fpath channel = forkIO $ do
music <- Mix.load fpath
_ <- Mix.playOn channel Mix.Once music
delayWhile $ Mix.playing channel
Mix.free music
I've never had the short sample (<1s wav file) not play, but the long song (.mp3) refuses to show up randomly. It happens about 1/5 times on my fast computer, and 4/5 times on my friend's slower computer. Maybe this has nothing to do with speed, but I'll leave this there.
Maybe I'm calling this wrong, it's basically only used as a side effect in do blocks, and I do nothing with the thread id.
Sorry if it's all over the place, I can't figure out if the problem comes from me or the library.
Thanks in advance.
openSUSE has recently updated its SDL2_mixer
system library to version 2.0.2 and that change has broken the build of this Haskell package:
[ 88s] In file included from dist/build/SDL/Raw/Mixer_hsc_make.c:1:0:
[ 88s] Mixer.hsc: In function ‘main’:
[ 88s] Mixer.hsc:196:16: error: ‘MIX_INIT_MODPLUG’ undeclared (first use in this function); did you mean ‘MIX_INIT_MOD’?
[ 88s] /usr/lib64/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
[ 88s] if ((x) < 0) \
[ 88s] ^
[ 88s] Mixer.hsc:196:16: note: each undeclared identifier is reported only once for each function it appears in
[ 88s] /usr/lib64/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
[ 88s] if ((x) < 0) \
[ 88s] ^
[ 88s] Mixer.hsc:199:16: error: ‘MIX_INIT_FLUIDSYNTH’ undeclared (first use in this function); did you mean ‘MIX_INIT_MID’?
[ 88s] /usr/lib64/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
[ 88s] if ((x) < 0) \
[ 88s] ^
[ 88s] Mixer.hsc:404:16: error: ‘MUS_MP3_MAD’ undeclared (first use in this function); did you mean ‘MUS_MP3’?
[ 88s] /usr/lib64/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
[ 88s] if ((x) < 0) \
[ 88s] ^
[ 88s] Mixer.hsc:406:16: error: ‘MUS_MODPLUG’ undeclared (first use in this function); did you mean ‘MUS_MOD’?
[ 88s] /usr/lib64/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
[ 88s] if ((x) < 0) \
[ 88s] ^
[ 88s] compiling dist/build/SDL/Raw/Mixer_hsc_make.c failed (exit code 1)
[ 88s] command was: /usr/bin/gcc -c dist/build/SDL/Raw/Mixer_hsc_make.c -o dist/build/SDL/Raw/Mixer_hsc_make.o -fno-stack-protector -fno-stack-protector -fuse-ld=bfd -D__GLASGOW_HASKELL__=802 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -I/usr/include/SDL2 -D_REENTRANT -Idist/build/autogen -Idist/build/global-autogen -include dist/build/autogen/cabal_macros.h -I/usr/include/SDL2 -I/usr/lib64/ghc-8.2.2/vector-0.12.0.1-IUGn3M9mkBh8CyXcBnfTR4/include -I/usr/lib64/ghc-8.2.2/primitive-0.6.2.0-EI3NK1Xfv9zEcRtyXK2EwZ/include -I/usr/lib64/ghc-8.2.2/time-1.8.0.2/include -I/usr/lib64/ghc-8.2.2/bytestring-0.10.8.2/include -I/usr/lib64/ghc-8.2.2/base-4.10.1.0/include -I/usr/lib64/ghc-8.2.2/integer-gmp-1.0.1.0/include -I/usr/lib64/ghc-8.2.2/include -I/usr/lib64/ghc-8.2.2/include/
Is this a known issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.