def main(): parser = get_cmd_line_parser(description=__doc__) ParserArguments.filename(parser) ParserArguments.tempo(parser) ParserArguments.framerate(parser) ParserArguments.set_defaults(parser) ParserArguments.best(parser) args = parser.parse_args() defaults.framerate = args.framerate song = Stream() roots = 'ABCDEFG' scales = [scale.MajorScale, scale.MinorScale, scale.WholeToneScale, scale.ChromaticScale] print('Choosing a random scale from Major, Minor, Whole Tone, Chromatic.') rscale = random.choice(scales)(Pitch(random.choice(roots))) print('Using: %s' % rscale.name) print('Generating a score...') random_note_count = 50 random_note_speeds = [0.5, 1] print('100 Random 1/8th and 1/4th notes in rapid succession...') for i in range(random_note_count): note = Note(random.choice(rscale.pitches)) note.duration.quarterLength = random.choice(random_note_speeds) song.append(note) scale_practice_count = 4 print('Do the scale up and down a few times... maybe %s' % scale_practice_count) rev = rscale.pitches[:] rev.reverse() updown_scale = rscale.pitches[:] updown_scale.extend(rev[1:-1]) print('updown scale: %s' % updown_scale) for count, pitch in enumerate(cycle(updown_scale)): print(' note %s, %s' % (count, pitch)) song.append(Note(pitch)) if count >= scale_practice_count * len(updown_scale): break print('Composition finished:') song.show('txt') if args.best: print('Audifying the song to file "{}"...') wave = audify_to_file(song, args.tempo, args.filename, verbose=True) else: wave = audify_basic(song, args.tempo, verbose=True) print('Writing Song to file "{}"...'.format(args.filename)) with wav_file_context(args.filename) as fout: fout.write_frames(wave.frames) return 0
def main(): parser = get_cmd_line_parser(description=__doc__) ParserArguments.filename(parser) ParserArguments.tempo(parser) ParserArguments.framerate(parser) ParserArguments.set_defaults(parser) ParserArguments.best(parser) args = parser.parse_args() defaults.framerate = args.framerate print('Generating Signal:') sig_gen = Generator() song = Waveform([]) qnl = quarter_note_length(args.tempo) # work = corpus.parse(numpy.random.choice(corpus.getComposer('bach'))) work = corpus.parse(numpy.random.choice(corpus.getCorePaths())) notes = work.flat.notes if args.best: audify_to_file(notes, args.tempo, args.filename, args.verbose) return 0 note_count = len(notes) try: for count, note in enumerate(notes): print('{}/{}: {} [{}]: {} {}'.format(count, note_count, note.offset, note.duration.quarterLength, note.pitch, note.pitch.frequency)) note_length = qnl * note.quarterLength start = seconds_to_frame(qnl * note.offset) print(' inserting {} seconds into frame {}'.format( note_length, start)) song = song.insert( start, sig_gen.sin_constant(note.pitch.frequency, length=note_length)) except KeyboardInterrupt: print('Stopping song generating here...') print('Writing Song {} to file {}...'.format(work.corpusFilepath, args.filename)) with wav_file_context(args.filename) as fout: fout.write_frames(song.frames) return 0
def main(): parser = get_cmd_line_parser(description=__doc__) ParserArguments.filename(parser) ParserArguments.tempo(parser) ParserArguments.framerate(parser) parser.add_argument('-r', '--repo', help='The git repository to use.') ParserArguments.set_defaults(parser) args = parser.parse_args() defaults.framerate = args.framerate repo_data = scrape_repository_data(args.repo) song = compose_repository_song(repo_data) notes = song.flat.notes waveform = audify(notes, args.tempo, args.verbose) with wav_file_context(args.filename) as fout: fout.write_frames(waveform.frames) return 0
def main(): parser = get_cmd_line_parser(description=__doc__) ParserArguments.filename(parser) ParserArguments.tempo(parser) ParserArguments.framerate(parser) ParserArguments.set_defaults(parser) args = parser.parse_args() defaults.framerate = args.framerate print('Generating Signal:') work = corpus.parse(numpy.random.choice(corpus.getCorePaths())) notes = work.flat.notes waveform = audify(notes, args.tempo, args.verbose) print('Writing Song {} to file {}...'.format(work.corpusFilepath, args.filename)) with wav_file_context(args.filename) as fout: fout.write_frames(waveform.frames) return 0
def main(): parser = get_cmd_line_parser(description=__doc__) ParserArguments.filename(parser) ParserArguments.tempo(parser) ParserArguments.framerate(parser) ParserArguments.set_defaults(parser) args = parser.parse_args() defaults.framerate = args.framerate print('Generating Signal:') work = corpus.parse(numpy.random.choice(corpus.getCorePaths())) notes = work.flat.notes waveform = audify(notes, args.tempo, args.verbose) print('Writing Song {} to file {}...'.format( work.corpusFilepath, args.filename)) with wav_file_context(args.filename) as fout: fout.write_frames(waveform.frames) return 0