[PATCH 0/2] Enable music playback in OpenTTD

  • Done
  • quality assurance status badge
Details
One participant
  • Liliana Marie Prikler
Owner
unassigned
Submitted by
Liliana Marie Prikler
Severity
normal
L
L
Liliana Marie Prikler wrote on 6 Nov 2021 15:11
(address . guix-patches@gnu.org)
c403bef5a9b99508150e1626bf529d73391244c8.camel@gmail.com
This series makes it so that OpenTTD can play music via fluidsynth.
In order to do so, the FreePats GM soundfont [1] is packaged as SF2 file.
I'm using the prebuilt SF2 file here, as I haven't yet found tools that'd
bundle the sources into a single file (the tools that FreePats themselves
provide could bundle individual sountfonts). Are there any Guix+MIDI
engineers here, who could give me a few pointers?

Cheers,
Liliana


Liliana Prikler (2):
gnu: Add freepats-gm.
gnu: openttd: Let the music play.

gnu/packages/audio.scm | 45 ++++++++++++++++++++++++++++++++++++++++++
gnu/packages/games.scm | 12 ++++++++++-
2 files changed, 56 insertions(+), 1 deletion(-)

--
2.33.1
L
L
Liliana Prikler wrote on 6 Nov 2021 14:06
[PATCH 1/2] gnu: Add freepats-gm.
(address . 51635@debbugs.gnu.org)
f06e3958f70a58b737aad4703163cafa0054e12c.camel@gmail.com
* gnu/packages/audio.scm (freepats-gm): New variable.
---
gnu/packages/audio.scm | 45 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)

Toggle diff (58 lines)
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 7cfbfc731d..eb5779340e 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -1936,6 +1936,51 @@ (define-public freepats
;; GPLv2+ with exception for compositions using these patches.
(license license:gpl2+)))
+(define-public freepats-gm
+ (package
+ (name "freepats-gm")
+ (version "20210329")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://freepats.zenvoid.org/SoundSets/"
+ "FreePats-GeneralMIDI/FreePatsGM-SF2-" version ".7z"))
+ (sha256
+ (base32
+ "19a1mp9yi33j2zff4mjvhrjz97dwwgjwzfdlf84j9xyydhx0crhc"))))
+ (build-system trivial-build-system)
+ (native-inputs
+ `(("p7zip" ,p7zip)))
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (let ((dir (string-append "FreePatsGM-SF2-" ,version))
+ (file (string-append "FreePatsGM-" ,version ".sf2"))
+ (out (string-append %output "/share/soundfonts"))
+ (doc (string-append %output "/share/doc/freepats-gm-" ,version)))
+ (use-modules (guix build utils))
+ (invoke (string-append (assoc-ref %build-inputs "p7zip") "/bin/7z")
+ "e" (assoc-ref %build-inputs "source")
+ (string-append dir "/" file)
+ (string-append dir "/gpl.txt")
+ (string-append dir "/cc0.txt")
+ (string-append dir "/readme.txt"))
+ (mkdir-p out)
+ (copy-file file (string-append out "/FreePatsGM.sf2"))
+ (mkdir-p doc)
+ (for-each
+ (lambda (file)
+ (copy-file file (string-append doc "/" file)))
+ (find-files "." "\\.txt$"))
+ #t)))
+ (home-page "https://freepats.zenvoid.org/SoundSets/general-midi.html")
+ (synopsis "General MIDI sound set")
+ (description "FreePats is a project to create a free (as in free software)
+collection of digital instruments for music production. This sound bank is a
+partial release of the General MIDI sound set.")
+ (license (list
+ license:gpl3+ ; with sampling exception
+ license:cc0))))
+
(define-public guitarix
(package
(name "guitarix")
--
2.33.1
L
L
Liliana Prikler wrote on 6 Nov 2021 14:06
[PATCH 2/2] gnu: openttd: Let the music play.
(address . 51635@debbugs.gnu.org)
dccd63a5dd0a503704b2fdde90d8ff69aed7b8f3.camel@gmail.com
* gnu/packages/games.scm (openttd)[inputs]: Remove timidity++.
Add fluidsynth and freepats-gm.
[#:phases]<patch-sources>: New phase.
---
gnu/packages/games.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

Toggle diff (32 lines)
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 14131fa065..47ed3fc1b4 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -4481,6 +4481,15 @@ (define-public openttd
(list (string-append "-DCMAKE_INSTALL_BINDIR=" out "/bin")))
#:phases
(modify-phases %standard-phases
+ (add-after 'unpack 'patch-sources
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "src/music/fluidsynth.cpp"
+ (("default_sf\\[\\] = \\{" all)
+ (string-append all "
+\t/* Guix hardcoded :P */
+\t\"" (string-append (assoc-ref inputs "freepats-gm")
+ "/share/soundfonts/FreePatsGM.sf2") "\",
+")))))
(add-before 'check 'install-data
(lambda* (#:key inputs outputs #:allow-other-keys)
(for-each
@@ -4489,7 +4498,8 @@ (define-public openttd
(assoc-ref outputs "out")))
(list "opengfx" "openmsx" "opensfx")))))))
(inputs
- `(("timidity++" ,timidity++)
+ `(("fluidsynth" ,fluidsynth)
+ ("freepats-gm" ,freepats-gm)
,@(package-inputs openttd-engine)))
(native-inputs
`(("opengfx" ,openttd-opengfx)
--
2.33.1
L
L
Liliana Marie Prikler wrote on 19 Apr 2022 20:39
(address . 51635-done@debbugs.gnu.org)
dc28e4581a356230d81a7cc155e4a0f40737e047.camel@gmail.com
Pushed this with a bunch of style changes to master.
Closed
?