Example #1
0
def percusstion_test():
    bass_base = Subtraction(SineWaveOscillator(frequency=40.0),
                            Amplifier(source=SquareWaveOscillator(frequency=80.0, duty=0.125),
                                      gain=1,
                                      attenuate=0.075))

    bass_drum = Multiplication(bass_base,
                               LFO(oscillator_class=SawWaveOscillator, frequency=1.0, duty=0.5))

    snare_drum = Multiplication(NoiseGenerator(frequency=6000.0),
                                LFO(oscillator_class=SawWaveOscillator, frequency=1.0, duty=0.25))

    hihat = Multiplication(NoiseGenerator(frequency=44100.0),
                           LFO(oscillator_class=SawWaveOscillator, frequency=4.0, duty=0.25))


    mixer = Mixer()
    mixer.add_track(0, "bus_drum", bass_drum)
    mixer.add_track(1, "snare_drum", snare_drum)
    mixer.add_track(2, "hihat", hihat)

    amplifire = Amplifier(source=mixer, gain=Config.ValueRange[0], attenuate=1.0)
    sink = WaveFileSink(output_file_name="output.wav")
    clock = Clock(end=Config.SampleRate * 3)

    renderer = Renderer(clock=clock, source=amplifire, sink=sink)
    renderer.do_rendering()
Example #2
0
def compiler_test():
    mmls = ("t115o5l8f2r8cfa>c<ar8fgr8ggr8d4r8gfr8ef2r8cfa>c<ar8fg-r8g-g-r8f1r8",
            "t115o4l8a2r8aa>cfcr8<ab-r8b-b-r8b-4r8b-b-r8b-a2r8aa>cfcr8<ab-r8b-b-r8a1r8",
            "t115o2l16v6f.r32f.r32f.r32f.r32r4f.r32f.r32f.r32f.r32r4"
            "f.r32f.r32f.r32f.r32r4f.r32f.r32f.r32f.r32r4"
            "f.r32f.r32f.r32f.r32r4f.r32f.r32f.r32f.r32r4"
            "f.r32f.r32f.r32f.r32r8f1r8")


    mml_compiler = MMLCompiler()
    sequences = [mml_compiler.to_sequence(mml) for mml in mmls]
    tones = [Tone(), Tone(), SquareWaveOscillator()]

    seq = Sequencer()
    seq.add_track(0, "track_0", tones[0], tones[0])
    seq.add_track(1, "track_1", tones[1], tones[1])
    seq.add_track(2, "track_3", tones[2], tones[2])

    seq.add_sequence(0, sequences[0])
    seq.add_sequence(1, sequences[1])
    seq.add_sequence(2, sequences[2])

    sink = WaveFileSink(output_file_name="output.wav")
    clock = Clock()

    renderer = Renderer(clock=clock, source=seq, sink=sink)
    renderer.do_rendering()
Example #3
0
def main():
    osc = SquareWaveOscillator(frequency=1000.0)
    amp = Amplifeir(source=osc, gain=Config.MaxGain, attenuate=0.55555)
    sink = WaveFileSink(output_file_name="output.wav")

    clock = Clock(end=Config.SampleRate)

    renderer = Renderer(clock=clock, source=amp, sink=sink)
    renderer.do_rendering()
Example #4
0
def main():
    osc = MySineWaveOscillator(frequency=220.0)
    amp = Amplifeir(source=osc, gain=Config.MaxGain, attenuate=0.5)
    sink = WaveFileSink(output_file_name="output.wav")

    output_seconds = 2;
    clock = Clock(end=Config.SampleRate * output_seconds)

    renderer = Renderer(clock=clock, source=amp, sink=sink)
    renderer.do_rendering()
Example #5
0
def main():
    mml_compiler = MMLCompiler()
    music_sequence = mml_compiler.to_sequence(MML)

    osc = SquareWaveOscillator()
    sequencer = Sequencer()
    sequencer.add_track(0, "tone1", osc, osc)
    sequencer.add_sequence(0, music_sequence)

    sink = WaveFileSink(output_file_name="output.wav")
    clock = Clock()
    renderer = Renderer(clock=clock, source=sequencer, sink=sink)
    renderer.do_rendering()
Example #6
0
def generateWavFile(yPosArray, tempo, volume):
    yPosMin = min(yPosArray)
    my_compiler = MyCompiler(yPosMin, tempo=tempo, volume=volume)
    sequencer = Sequencer()
    tone1 = Tone()
    sequencer.add_track(0, "manual", tone1, tone1)
    sequence = my_compiler.get_sequence(yPosArray)
    sequencer.add_sequence(0, sequence)

    sink = WaveFileSink(output_file_name=outputWavFileName)
    clock = Clock()
    renderer = Renderer(clock=clock, source=sequencer, sink=sink)
    renderer.do_rendering()
Example #7
0
def chorus_test():
    osc1 = SquareWaveOscillator(frequency=440.0)
    osc2 = Inverter(source=FrequencyModulator(source=osc1,
                                              delta=Multiplication(
                                                  ConstantValueGenerator(2.0),
                                                  LFO(oscillator_class=SineWaveOscillator,
                                                      frequency=3.0))))


    mixer = Mixer()
    mixer.add_track(0, "base_tone", Gate(source=osc1, state=(True, False)))
    mixer.add_track(1, "detuned_tone", Gate(source=osc2, state=(True, True)))

    amplifire = Amplifier(source=mixer, gain=Config.MaxGain, attenuate=0.75)
    sink = WaveFileSink(output_file_name="output.wav")
    clock = Clock(end=Config.SampleRate)

    renderer = Renderer(clock=clock, source=amplifire, sink=sink)
    renderer.do_rendering()
Example #8
0
def main():
    mml_compiler1 = MMLCompiler()
    mml_compiler2 = MMLCompiler()
    mml_compiler3 = MMLCompiler()
    music_sequence1 = mml_compiler1.to_sequence(MML1)
    music_sequence2 = mml_compiler2.to_sequence(MML2)
    music_sequence3 = mml_compiler3.to_sequence(MML3)

    osc1 = SquareWaveOscillator()
    osc2 = SquareWaveOscillator()
    osc3 = SquareWaveOscillator()
    sequencer = Sequencer()
    sequencer.add_track(0, "tone1", osc1, osc1) # 一つ目のoscが周波数をかえる先(オシレーター)、2つ目はデータを取り出す元(通常ならばアンプとかミキサー)
    sequencer.add_track(1, "tone2", osc2, osc2)
    sequencer.add_track(2, "tone3", osc3, osc3)

    sequencer.add_sequence(0, music_sequence1)
    sequencer.add_sequence(1, music_sequence2)
    sequencer.add_sequence(2, music_sequence3)

    sink = WaveFileSink(output_file_name="output.wav")
    clock = Clock()
    renderer = Renderer(clock=clock, source=sequencer, sink=sink)
    renderer.do_rendering()