def test_scale_acending_iteratation_range(): cs = ChromaticScale(Tone(0)) # A4 series = list(cs.acending()) assert [x._tone_name for x in series] == [ 'A4', 'B♭4', 'B4', 'C4', 'C♯4', 'D4', 'E♭4', 'E4', 'F4', 'F♯4', 'G4', 'G♯4', 'A5' ]
def test_scale_decending_iteratation(): cs = ChromaticScale(Tone(0)) # A4 series = list(take(cs.decending(), 13)) assert [x._tone_name for x in series] == [ 'A4', 'G♯3', 'G3', 'F♯3', 'F3', 'E3', 'E♭3', 'D3', 'C♯3', 'C3', 'B3', 'B♭3', 'A3' ]
def test_scale_acending_iteratation_range(): cs = ChromaticScale(Tone(0)) # A4 series = list(take(cs.forever_acending(), 25)) assert [x._tone_name for x in series] == [ 'A4', 'B♭4', 'B4', 'C4', 'C♯4', 'D4', 'E♭4', 'E4', 'F4', 'F♯4', 'G4', 'G♯4', 'A5', 'B♭5', 'B5', 'C5', 'C♯5', 'D5', 'E♭5', 'E5', 'F5', 'F♯5', 'G5', 'G♯5', 'A6' ]
def test_scale_acending_iteratation(): cs = HarmonicMinorScale(Tone(100)) # A4 series = list(take(cs.acending(), 8)) assert [x._tone_name for x in series] == HARMONIC_MINOR_SCALE
def test_scale_acending_iteratation(): cs = NaturalMinorScale(Tone(1300)) # Bb5 series = list(take(cs.decending(), 8)) assert ([x._tone_name for x in series] == list( reversed(NATURAL_MINOR_SCALE)))
def test_scale_acending_iteratation(): cs = NaturalMinorScale(Tone(100)) # Bb4 series = list(take(cs.acending(), 8)) assert [x._tone_name for x in series] == NATURAL_MINOR_SCALE
def test_tone_tone(): assert Tone.from_string("E♭4").value == 600 assert Tone.from_string("A4").value == 0 assert Tone.from_string("C102").value == 117900 assert Tone.from_string("C♯2").value == -2000
def test_scale_decending_iteratation(): cs = MajorScale(Tone(1200)) # A5 series = list(take(cs.decending(), 8)) assert [x._tone_name for x in series] == list(reversed(SCALE))
from muse.tone import Tone from fluidsynth.aio import AsyncSynth import asyncio import time synth = AsyncSynth("/home/tag/piano/Full Grand Piano.sf2", config={ "audio.driver": "pulseaudio", "synth.reverb.active": "yes" }) synth.start() time.sleep(1) A3 = Tone.from_string("A3") D3 = Tone.from_string("D3") F2 = Tone.from_string("F2") @asyncio.coroutine def play_chord(note, chord_, duration, lag): yield from asyncio.sleep(lag) yield from synth.chord(0, [x.to_midi() for x in note.chord(chord_)], 80, duration) @asyncio.coroutine def main(): yield from asyncio.gather( asyncio. async (play_chord(D3, MAJOR_SEVENTH, 5.0, 0)),
def test_minor_chord_a4(): c = Tone(0).chord(MINOR) assert [x._tone_name for x in c] == ['A4', 'C4', 'E4']
def test_tone_name_Eb4(): tone = Tone(600) x = tone._tone_name assert x == "E♭4" assert note_to_cents("E♭", 4) == 600
def test_tone_name_Bb(): tone = Tone(100) x = tone._tone_name assert x == "B♭4" assert note_to_cents("B♭", 4) == 100
from fluidsynth.aio import AsyncSynth import asyncio import time synth = AsyncSynth("/home/tag/piano/Full Grand Piano.sf2", config={ "audio.driver": "pulseaudio", "synth.reverb.active": "yes" }) synth.start() time.sleep(1) A3 = Tone.from_string("A3") D3 = Tone.from_string("D3") F2 = Tone.from_string("F2") @asyncio.coroutine def play_chord(note, chord_, duration, lag): yield from asyncio.sleep(lag) yield from synth.chord(0, [x.to_midi() for x in note.chord(chord_)], 80, duration) @asyncio.coroutine def main(): yield from asyncio.gather( asyncio.async(play_chord(D3, MAJOR_SEVENTH, 5.0, 0)), asyncio.async(play_chord(A3, MAJOR, 5.0, 2)),
def test_scale_acending_iteratation(): cs = HarmonicMinorScale(Tone(1200)) # A5 series = list(take(cs.decending(), 8)) assert ([x._tone_name for x in series] == list( reversed(HARMONIC_MINOR_SCALE)))
def test_tone_name_Eb5(): tone = Tone(1200 + 600) x = tone._tone_name assert x == "E♭5" assert note_to_cents("E♭", 5) == 1200 + 600
def test_major_chord_a4(): c = Tone(0).chord(MAJOR) assert [x._tone_name for x in c] == ['A4', 'C♯4', 'E4']
def test_tone_name_Eb5_plus(): tone = Tone(605) x = tone._tone_name assert x == "5 cents above E♭4"
# the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from muse.tone import Tone from muse.intervals import (PERFECT_FIFTH, AUGMENTED_SEVENTH) F2 = Tone(-1600) def test_perfect_fifth(): assert F2._tone_name == "F2" assert F2.relative_tone(PERFECT_FIFTH)._tone_name == "C3" def test_augmented_seventh(): assert F2._tone_name == "F2" assert F2.relative_tone(AUGMENTED_SEVENTH)._tone_name == "F3"
def test_tone_str_Eb5_plus_str(): tone = Tone(605) assert str(tone) == "<Tone: 5 cents above E♭4>"
synth = Synth("/home/tag/organ.sf2", config={"audio.driver": "pulseaudio"}) synth.start() def take(it, n): for _ in range(n): yield next(it) def play_chord(chord, duration): for c in chord: synth.noteon(0, c.to_midi(), 80) time.sleep(duration) for c in chord: synth.noteoff(0, c.to_midi()) while True: for prog in [ MAJOR, MINOR, AUGMENTED, DIMINISHED, DIMINISHED_SEVENTH, HALF_DIMINISHED_SEVENTH, DOMINANT_SEVENTH, MAJOR_SEVENTH, AUGMENTED_SEVENTH, AUGMENTED_MAJOR_SEVENTH ]: for note in take(NaturalMinorScale(Tone(0)).acending(), 7): play_chord(note.chord(prog), 0.25) synth.shutdown()
def test_scale_acending_iteratation(): cs = MajorScale(Tone(0)) # A4 series = list(take(cs.acending(), 8)) assert [x._tone_name for x in series] == SCALE