File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55install :
66 python setup.py install
77
8+ test :
9+ (cd unittest; python run_tests.py)
10+
11+ test-fluidsynth :
12+ (cd unittest; python run_fluidsynth_tests.py)
13+
14+ test-lilypond :
15+ (cd unittest; python run_lilypond_tests.py)
16+
17+ test-all : test test-fluidsynth test-lilypond
18+
819clean :
920 rm -rf build/ dist/
1021
Original file line number Diff line number Diff line change 11from __future__ import absolute_import
22
3- # -*- coding: utf-8 -*-
4- import sys
3+ import os
4+ import shutil
5+ import tempfile
6+ import time
7+ import unittest
8+
59from six .moves import range
610
7- sys .path += ["../" ]
8- from mingus .midi import fluidsynth
911from mingus .containers import *
10- import unittest
11- import time
12+ from mingus .midi import fluidsynth
1213from mingus .midi .sequencer_observer import SequencerObserver
1314
1415
1516class test_fluidsynth (unittest .TestCase ):
1617 def setUp (self ):
17- fluidsynth .init (
18- "/home/bspaans/workspace/fluidsynth/ChoriumRevA.SF2" , file = "test.wav"
19- )
18+ soundfont = os .getenv ("SOUNDFONT" )
19+ if soundfont is None :
20+ raise ValueError (
21+ "A soundfont (*.sf2) file path must be provided in the SOUNDFONT environment variable"
22+ )
23+
24+ self .tempdir = tempfile .mkdtemp ()
25+ output_file = os .path .join (self .tempdir , "test.wav" )
26+
27+ fluidsynth .init (soundfont , file = output_file )
2028 fluidsynth .set_instrument (0 , 0 )
2129 s = SequencerObserver ()
2230 fluidsynth .midi .attach (s )
2331
32+ def tearDown (self ):
33+ shutil .rmtree (self .tempdir )
34+
2435 def test_bar_velocity (self ):
2536 b = Bar ()
2637 n = Note ("C" )
Original file line number Diff line number Diff line change 11from __future__ import absolute_import
22
3- # -*- coding: utf-8 -*-
3+ import os
4+ import shutil
45import sys
6+ import tempfile
7+ import unittest
58from six .moves import map
69
7- sys .path += ["../" ]
8- import unittest
910import mingus .extra .lilypond as LilyPond
1011import mingus .core .value as value
1112from mingus .containers .note import Note
1718
1819class test_LilyPond (unittest .TestCase ):
1920 def setUp (self ):
21+ # LilyPond output files are created in current working directory
22+ self .tempdir = tempfile .mkdtemp ()
23+ self .oldcwd = os .getcwd ()
24+ os .chdir (self .tempdir )
25+
2026 self .commonbar = Bar ()
2127 self .ebar = Bar ("E" , (4 , 4 ))
2228 self .fbar = Bar ("F" , (6 , 8 ))
@@ -44,6 +50,10 @@ def setUp(self):
4450 self .composition2 .add_track (self .track1 )
4551 self .composition2 .add_track (self .track2 )
4652
53+ def tearDown (self ):
54+ os .chdir (self .oldcwd )
55+ shutil .rmtree (self .tempdir )
56+
4757 def test_from_Note (self ):
4858 self .assertEqual (LilyPond .from_Note (Note ("C" ), standalone = False ), "c'" )
4959 self .assertEqual (LilyPond .from_Note (Note ("C#" ), standalone = False ), "cis'" )
You can’t perform that action at this time.
0 commit comments