Ejemplo n.º 1
0
                                      mode="full")
    print("Convolution (including mirrored data) is %s seconds or %s frames" %
          (frame_to_seconds(len(convolution_data),
                            framerate=sg.framerate), len(convolution_data)))

    print("Normalizing Convolution Amplitude")
    convolution = Waveform(
        normalize(convolution_data[:int(len(convolution_data) / 2)]))

    if args.plot:
        _, subplots = pyplot.subplots(4, 1)
        subplots[0].plot(main_track.frames)
        subplots[0].set_title('Main Track 440.0 and 660.0 Hz - Root and Fifth')
        subplots[1].plot(harmony_track.frames)
        subplots[1].set_title('Harmony Major Third (550.0 Hz)')
        subplots[2].plot(preprocessed_harmony_track.frames)
        subplots[2].set_title('Preprocessed Harmony Track')
        subplots[3].plot(convolution.frames)
        subplots[3].set_title('Convolved track of the two waveforms.')
        pyplot.show()
    else:
        from potty_oh.wav_file import wav_file_context
        with wav_file_context(args.filename) as fout:
            fout.write_frames(convolution.frames)

    return 0


if __name__ == "__main__":
    common.call_main(main)
Ejemplo n.º 2
0
The music21 libaries have a lot of purposes beyond what I need so for now I
think all I need is to know how to access the note pitches and their positions
and durations within the work. From those three bits of info I can then
construct a waveform representing that music given a tempo to define the length
of a quarter note.
"""

import numpy

from music21 import corpus

from potty_oh.common import get_cmd_line_parser
from potty_oh.common import call_main


def main():
    parser = get_cmd_line_parser(description=__doc__)
    parser.parse_args()

    work_path = numpy.random.choice(corpus.getComposer('bach'))
    work = corpus.parse(work_path)
    for note in work.flat.notes:
        print('{} [{}]: {} {}'.format(note.offset, note.duration.quarterLength,
                                      note.pitch, note.frequency))
    return 0


if __name__ == "__main__":
    call_main(main)
Ejemplo n.º 3
0
    common.ParserArguments.length(parser)
    common.ParserArguments.framerate(parser)
    common.ParserArguments.set_defaults(parser, type='constant',
                                        length=2.0)
    args = parser.parse_args()
    common.defaults.framerate = args.framerate

    sg = Generator(length=args.length, verbose=args.debug)

    key = Key()
    unison = sg.sin_constant(key.interval(Interval.unison))
    maj_third = sg.sin_constant(key.interval(Interval.major_third))
    min_third = sg.sin_constant(key.interval(Interval.minor_third))
    fifth = sg.sin_constant(key.interval(Interval.fifth))

    powerchord = unison.mix_down(fifth)

    maj_triad = powerchord.mix_down(maj_third)
    min_triad = mix_down(powerchord, min_third)

    with wav_file_context(args.filename) as fout:
        fout.write_frames(powerchord.frames)
        fout.write_frames(maj_triad.frames)
        fout.write_frames(min_triad.frames)

    return 0


if __name__ == "__main__":
    common.call_main(main)
Ejemplo n.º 4
0
The music21 libaries have a lot of purposes beyond what I need so for now I
think all I need is to know how to access the note pitches and their positions
and durations within the work. From those three bits of info I can then
construct a waveform representing that music given a tempo to define the length
of a quarter note.
"""

import numpy

from music21 import corpus

from potty_oh.common import get_cmd_line_parser
from potty_oh.common import call_main


def main():
    parser = get_cmd_line_parser(description=__doc__)
    parser.parse_args()

    work_path = numpy.random.choice(corpus.getComposer('bach'))
    work = corpus.parse(work_path)
    for note in work.flat.notes:
        print('{} [{}]: {} {}'.format(note.offset, note.duration.quarterLength,
                                      note.pitch, note.frequency))
    return 0


if __name__ == "__main__":
    call_main(main)