* [Buildroot] [PATCH 1/2] package/python-midiutil: new package
@ 2023-01-03 20:00 Julien Olivain
2023-01-03 20:00 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_fluidsynth.py: new runtime test Julien Olivain
2023-07-30 10:59 ` [Buildroot] [PATCH 1/2] package/python-midiutil: new package Thomas Petazzoni via buildroot
0 siblings, 2 replies; 4+ messages in thread
From: Julien Olivain @ 2023-01-03 20:00 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain, Asaf Kahlon, Thomas Petazzoni
A pure python library for creating multi-track MIDI files.
https://github.com/MarkCWirt/MIDIUtil
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested on branch master at commit e593656 with commands:
make check-package
...
0 warnings generated
python3 -m flake8 \
support/testing/tests/package/sample_python_midiutil.py \
support/testing/tests/package/test_python_midiutil.py
[no-output]
support/testing/run-tests \
-d dl -o output_folder \
tests.package.test_python_midiutil.TestPythonPy3MidiUtil
...
OK
---
DEVELOPERS | 3 +++
package/Config.in | 1 +
package/python-midiutil/Config.in | 6 +++++
package/python-midiutil/python-midiutil.hash | 5 ++++
package/python-midiutil/python-midiutil.mk | 14 +++++++++++
.../tests/package/sample_python_midiutil.py | 23 +++++++++++++++++++
.../tests/package/test_python_midiutil.py | 11 +++++++++
7 files changed, 63 insertions(+)
create mode 100644 package/python-midiutil/Config.in
create mode 100644 package/python-midiutil/python-midiutil.hash
create mode 100644 package/python-midiutil/python-midiutil.mk
create mode 100644 support/testing/tests/package/sample_python_midiutil.py
create mode 100644 support/testing/tests/package/test_python_midiutil.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 8399dcc7af..af497114dc 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1688,6 +1688,7 @@ F: package/ola/
F: package/ptm2human/
F: package/python-distro/
F: package/python-gnupg/
+F: package/python-midiutil/
F: package/python-pyalsa/
F: package/riscv-isa-sim/
F: package/tinycompress/
@@ -1695,6 +1696,7 @@ F: package/z3/
F: package/zynaddsubfx/
F: support/testing/tests/package/sample_python_distro.py
F: support/testing/tests/package/sample_python_gnupg.py
+F: support/testing/tests/package/sample_python_midiutil.py
F: support/testing/tests/package/sample_python_pyalsa.py
F: support/testing/tests/package/test_hwloc.py
F: support/testing/tests/package/test_ncdu.py
@@ -1703,6 +1705,7 @@ F: support/testing/tests/package/test_ola.py
F: support/testing/tests/package/test_ola/
F: support/testing/tests/package/test_python_distro.py
F: support/testing/tests/package/test_python_gnupg.py
+F: support/testing/tests/package/test_python_midiutil.py
F: support/testing/tests/package/test_python_pyalsa.py
F: support/testing/tests/package/test_z3.py
diff --git a/package/Config.in b/package/Config.in
index 995dae2c57..4157fe1214 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1123,6 +1123,7 @@ menu "External python modules"
source "package/python-matplotlib/Config.in"
source "package/python-mbstrdecoder/Config.in"
source "package/python-memory-profiler/Config.in"
+ source "package/python-midiutil/Config.in"
source "package/python-mimeparse/Config.in"
source "package/python-minimalmodbus/Config.in"
source "package/python-mistune/Config.in"
diff --git a/package/python-midiutil/Config.in b/package/python-midiutil/Config.in
new file mode 100644
index 0000000000..c496e60421
--- /dev/null
+++ b/package/python-midiutil/Config.in
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PYTHON_MIDIUTIL
+ bool "python-midiutil"
+ help
+ A pure python library for creating multi-track MIDI files.
+
+ https://github.com/MarkCWirt/MIDIUtil
diff --git a/package/python-midiutil/python-midiutil.hash b/package/python-midiutil/python-midiutil.hash
new file mode 100644
index 0000000000..88340a23b8
--- /dev/null
+++ b/package/python-midiutil/python-midiutil.hash
@@ -0,0 +1,5 @@
+# md5, sha256 from https://pypi.org/pypi/midiutil/json
+md5 948c16c74e7355268158f227b710edce MIDIUtil-1.2.1.tar.gz
+sha256 79fa983bd1efc60785f68a8fe78fa8f45b8d7ec5898bf7cb7f3f7f3336d6a90a MIDIUtil-1.2.1.tar.gz
+# Locally computed sha256 checksums
+sha256 8d5bdaebe8445a4c2dc812c205eb5455ba123aa1af8503cc88712115ab7c97ef License.txt
diff --git a/package/python-midiutil/python-midiutil.mk b/package/python-midiutil/python-midiutil.mk
new file mode 100644
index 0000000000..cb7e8f6ccb
--- /dev/null
+++ b/package/python-midiutil/python-midiutil.mk
@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-midiutil
+#
+################################################################################
+
+PYTHON_MIDIUTIL_VERSION = 1.2.1
+PYTHON_MIDIUTIL_SOURCE = MIDIUtil-$(PYTHON_MIDIUTIL_VERSION).tar.gz
+PYTHON_MIDIUTIL_SITE = https://files.pythonhosted.org/packages/f5/44/fde6772d8bfaea64fcf5eb948124d0a5fdf5f848b14ac22a23ced53e562d
+PYTHON_MIDIUTIL_SETUP_TYPE = setuptools
+PYTHON_MIDIUTIL_LICENSE = MIT
+PYTHON_MIDIUTIL_LICENSE_FILES = License.txt
+
+$(eval $(python-package))
diff --git a/support/testing/tests/package/sample_python_midiutil.py b/support/testing/tests/package/sample_python_midiutil.py
new file mode 100644
index 0000000000..58bf1fbccb
--- /dev/null
+++ b/support/testing/tests/package/sample_python_midiutil.py
@@ -0,0 +1,23 @@
+#! /usr/bin/env python3
+
+# Taken from:
+# https://github.com/MarkCWirt/MIDIUtil/blob/1.2.1/examples/c-major-scale.py
+
+from midiutil import MIDIFile
+
+degrees = [60, 62, 64, 65, 67, 69, 71, 72] # MIDI note number
+track = 0
+channel = 0
+time = 0 # In beats
+duration = 1 # In beats
+tempo = 60 # In BPM
+volume = 100 # 0-127, as per the MIDI standard
+
+MyMIDI = MIDIFile(1) # One track
+MyMIDI.addTempo(track, time, tempo)
+
+for i, pitch in enumerate(degrees):
+ MyMIDI.addNote(track, channel, pitch, time + i, duration, volume)
+
+with open("major-scale.mid", "wb") as output_file:
+ MyMIDI.writeFile(output_file)
diff --git a/support/testing/tests/package/test_python_midiutil.py b/support/testing/tests/package/test_python_midiutil.py
new file mode 100644
index 0000000000..302fbfb1ed
--- /dev/null
+++ b/support/testing/tests/package/test_python_midiutil.py
@@ -0,0 +1,11 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3MidiUtil(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_MIDIUTIL=y
+ """
+ sample_scripts = ["tests/package/sample_python_midiutil.py"]
--
2.39.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Buildroot] [PATCH 2/2] support/testing/tests/package/test_fluidsynth.py: new runtime test
2023-01-03 20:00 [Buildroot] [PATCH 1/2] package/python-midiutil: new package Julien Olivain
@ 2023-01-03 20:00 ` Julien Olivain
2023-07-30 11:00 ` Thomas Petazzoni via buildroot
2023-07-30 10:59 ` [Buildroot] [PATCH 1/2] package/python-midiutil: new package Thomas Petazzoni via buildroot
1 sibling, 1 reply; 4+ messages in thread
From: Julien Olivain @ 2023-01-03 20:00 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain, Asaf Kahlon, Thomas Petazzoni
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested on branch master at commit e593656 with commands:
make check-package
...
0 warnings generated
python3 -m flake8 \
support/testing/tests/package/test_fluidsynth.py \
support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/check_notes.py \
support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/gen_midi_file.py
[no-output]
support/testing/run-tests \
-d dl -o output_folder \
tests.package.test_fluidsynth.TestFluidsynth
...
OK
---
DEVELOPERS | 2 +
.../testing/tests/package/test_fluidsynth.py | 61 +++++++++++++++++++
.../rootfs-overlay/root/check_notes.py | 24 ++++++++
.../rootfs-overlay/root/gen_midi_file.py | 23 +++++++
4 files changed, 110 insertions(+)
create mode 100644 support/testing/tests/package/test_fluidsynth.py
create mode 100755 support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/check_notes.py
create mode 100755 support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/gen_midi_file.py
diff --git a/DEVELOPERS b/DEVELOPERS
index af497114dc..a701485c31 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1698,6 +1698,8 @@ F: support/testing/tests/package/sample_python_distro.py
F: support/testing/tests/package/sample_python_gnupg.py
F: support/testing/tests/package/sample_python_midiutil.py
F: support/testing/tests/package/sample_python_pyalsa.py
+F: support/testing/tests/package/test_fluidsynth.py
+F: support/testing/tests/package/test_fluidsynth/
F: support/testing/tests/package/test_hwloc.py
F: support/testing/tests/package/test_ncdu.py
F: support/testing/tests/package/test_octave.py
diff --git a/support/testing/tests/package/test_fluidsynth.py b/support/testing/tests/package/test_fluidsynth.py
new file mode 100644
index 0000000000..6b45959179
--- /dev/null
+++ b/support/testing/tests/package/test_fluidsynth.py
@@ -0,0 +1,61 @@
+import os
+
+import infra.basetest
+
+
+class TestFluidsynth(infra.basetest.BRTest):
+ # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it is
+ # armv5 and based on qemu versatilepb which is limited to 256MB of
+ # RAM. The test needs 1GB of RAM (larger initrd and soundfond is
+ # loaded in memory).
+ config = \
+ """
+ BR2_aarch64=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.86"
+ BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+ BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+ BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+ BR2_PACKAGE_AUBIO=y
+ BR2_PACKAGE_FLUIDSYNTH=y
+ BR2_PACKAGE_FLUIDSYNTH_LIBSNDFILE=y
+ BR2_PACKAGE_FLUID_SOUNDFONT=y
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_MIDIUTIL=y
+ BR2_ROOTFS_OVERLAY="{}"
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """.format(
+ # overlay to add helper test scripts
+ infra.filepath("tests/package/test_fluidsynth/rootfs-overlay"))
+
+ def test_run(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio")
+ kern = os.path.join(self.builddir, "images", "Image")
+ self.emulator.boot(arch="aarch64",
+ kernel=kern,
+ kernel_cmdline=["console=ttyAMA0"],
+ options=["-M", "virt", "-cpu", "cortex-a57", "-m", "1G", "-initrd", img])
+ self.emulator.login()
+
+ # Test the binary executes
+ self.assertRunOk("fluidsynth --version")
+
+ # Create a simple MIDI file programmatically
+ self.assertRunOk("/root/gen_midi_file.py /tmp/output.mid")
+
+ # Convert the MIDI file to a WAV file
+ cmd = "fluidsynth"
+ cmd += " -F /tmp/output.wav"
+ cmd += " /usr/share/soundfonts/FluidR3_GM.sf2"
+ cmd += " /tmp/output.mid"
+ self.assertRunOk(cmd)
+
+ # Extract notes in the WAV file with Aubio
+ self.assertRunOk("aubionotes /tmp/output.wav > /tmp/notes.txt")
+
+ # Check the extracted notes are the expected ones
+ self.assertRunOk("/root/check_notes.py < /tmp/notes.txt")
diff --git a/support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/check_notes.py b/support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/check_notes.py
new file mode 100755
index 0000000000..7301e14a9f
--- /dev/null
+++ b/support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/check_notes.py
@@ -0,0 +1,24 @@
+#! /usr/bin/env python3
+#
+# This script reads the output of the "aubionotes" command and
+# validates it contains three expected notes (A2, E3, A3) in the
+# correct order. Silences or other notes are allowed in between those
+# notes, to allow some flexibility.
+
+import sys
+
+found = 0
+notes = [57, 64, 69]
+
+for line in sys.stdin:
+ fields = line.split()
+ if len(fields) >= 1:
+ value = round(float(fields[0]))
+ if value == notes[found]:
+ found += 1
+ if found == len(notes):
+ print("Found all notes")
+ sys.exit(0)
+
+print("Error: all notes not found")
+sys.exit(1)
diff --git a/support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/gen_midi_file.py b/support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/gen_midi_file.py
new file mode 100755
index 0000000000..aa53a25af3
--- /dev/null
+++ b/support/testing/tests/package/test_fluidsynth/rootfs-overlay/root/gen_midi_file.py
@@ -0,0 +1,23 @@
+#! /usr/bin/env python3
+#
+# This script generates a MIDI file with only 3 notes: A2, E3, A3
+# usage: gen_midi_file.py [output-filename]
+
+import sys
+
+from midiutil import MIDIFile
+
+output_filename = "output.mid"
+if len(sys.argv) >= 2:
+ output_filename = sys.argv[1]
+
+notes = [57, 64, 69] # A2, E3, A3
+
+midi = MIDIFile()
+midi.addTempo(track=0, time=0, tempo=60)
+
+for i, p in enumerate(notes):
+ midi.addNote(track=0, channel=0, pitch=p, time=i, duration=1, volume=100)
+
+with open(output_filename, "wb") as output_file:
+ midi.writeFile(output_file)
--
2.39.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [Buildroot] [PATCH 1/2] package/python-midiutil: new package
2023-01-03 20:00 [Buildroot] [PATCH 1/2] package/python-midiutil: new package Julien Olivain
2023-01-03 20:00 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_fluidsynth.py: new runtime test Julien Olivain
@ 2023-07-30 10:59 ` Thomas Petazzoni via buildroot
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-07-30 10:59 UTC (permalink / raw)
To: Julien Olivain; +Cc: Asaf Kahlon, buildroot
On Tue, 3 Jan 2023 21:00:45 +0100
Julien Olivain <ju.o@free.fr> wrote:
> A pure python library for creating multi-track MIDI files.
>
> https://github.com/MarkCWirt/MIDIUtil
>
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Patch tested on branch master at commit e593656 with commands:
Applied to master, thanks.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-30 11:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-03 20:00 [Buildroot] [PATCH 1/2] package/python-midiutil: new package Julien Olivain
2023-01-03 20:00 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/test_fluidsynth.py: new runtime test Julien Olivain
2023-07-30 11:00 ` Thomas Petazzoni via buildroot
2023-07-30 10:59 ` [Buildroot] [PATCH 1/2] package/python-midiutil: new package Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox