-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ttm/music
- Loading branch information
Showing
10 changed files
with
162 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" Simple script that writes a chromatic scale on a WAV file. """ | ||
|
||
import music | ||
|
||
scale = [ | ||
261.63, # C4 | ||
277.18, # C#4 | ||
293.66, # D4 | ||
311.13, # D#4 | ||
329.63, # E4 | ||
349.23, # F4 | ||
369.99, # F#4 | ||
392.00, # G4 | ||
415.30, # G#4 | ||
440.00, # A4 | ||
466.16, # A#4 | ||
493.88 # B4 | ||
] | ||
|
||
sonic_vector = [] | ||
|
||
for note in scale: | ||
sound = music.core.synths.note(freq=note, | ||
duration=0.4) | ||
sonic_vector.append(sound) | ||
|
||
stack = music.utils.horizontal_stack(*sonic_vector) | ||
|
||
music.core.io.write_wav_mono(sonic_vector=stack, | ||
filename='chromatic_scale.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import music | ||
|
||
tables = music.legacy.tables.Basic() | ||
pe3 = music.structures.peals.PlainChanges.PlainChanges(3) | ||
tables = music.tables.PrimaryTables() | ||
pe3 = music.structures.PlainChanges(3) | ||
music.structures.symmetry.print_peal(pe3.act(), [0]) | ||
freqs = sum(pe3.act([220,440,330]), []) | ||
freqs = sum(pe3.act([220, 440, 330]), []) | ||
|
||
isynth = music.legacy.IteratorSynth.IteratorSynth() | ||
isynth = music.legacy.IteratorSynth() | ||
isynth.fundamental_frequency_sequence = freqs | ||
isynth.tab_sequence = [tables.sine, tables.triangle, tables.square, tables.saw] | ||
|
||
pcm_samples = music.utils.horizontal_stack(*[isynth.renderIterate() for i in range(len(freqs))]) | ||
pcm_samples = music.utils.horizontal_stack(*[isynth.renderIterate() | ||
for i in range(len(freqs))]) | ||
|
||
music.core.io.write_wav_mono(pcm_samples, 'isynth.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" Simple script that writes a pentatonic scale on a WAV file | ||
with different effects. | ||
""" | ||
|
||
import music | ||
|
||
noises = ['brown', 'pink', 'white', 'blue', 'violet', 'black'] | ||
sonic_vector = [] | ||
silence = music.core.synths.silence(duration=0.4) | ||
beep = music.core.synths.note(duration=0.1) | ||
|
||
for noise in noises: | ||
sonic_vector.append(music.core.synths.noises.noise(noise_type=noise)) | ||
sonic_vector.append(silence) | ||
sonic_vector.append(beep) | ||
sonic_vector.append(silence) | ||
|
||
sonic_vector.append(music.core.synths.noises.gaussian_noise()) | ||
|
||
stack = music.utils.horizontal_stack(*sonic_vector) | ||
music.core.io.write_wav_stereo(sonic_vector=stack, | ||
filename='noisy.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
""" Simple script that writes a pentatonic scale on a WAV file | ||
with different effects. | ||
""" | ||
|
||
import music | ||
|
||
scale = [ | ||
261.63, # C4 | ||
293.66, # D4 | ||
329.63, # E4 | ||
392.00, # G4 | ||
440.00 # A4 | ||
] | ||
|
||
sonic_vector = [] | ||
for note in scale: | ||
sound = music.core.synths.note(freq=note, | ||
duration=0.4) | ||
sonic_vector.append(sound) | ||
|
||
sonic_vector.append(music.core.synths.silence()) | ||
|
||
for note in scale: | ||
sound = music.core.synths.note_with_glissando(start_freq=note, | ||
end_freq=note+30, | ||
duration=0.4) | ||
sonic_vector.append(sound) | ||
|
||
sonic_vector.append(music.core.synths.silence()) | ||
|
||
for note in scale: | ||
sound = music.core.synths.note_with_vibrato(freq=note, | ||
duration=0.4) | ||
sonic_vector.append(sound) | ||
|
||
sonic_vector.append(music.core.synths.silence()) | ||
|
||
for note in scale: | ||
sound = music.core.synths.note_with_doppler(freq=note, | ||
duration=0.4) | ||
sonic_vector.append(sound) | ||
|
||
sonic_vector.append(music.core.synths.silence()) | ||
|
||
for note in scale: | ||
sound = music.core.synths.note_with_fm(freq=note, | ||
duration=0.4) | ||
sonic_vector.append(sound) | ||
|
||
stack = music.utils.horizontal_stack(*sonic_vector) | ||
music.core.io.write_wav_stereo(sonic_vector=stack, | ||
filename='penta_effects.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import music | ||
from music.legacy import Being | ||
|
||
# 1) start a ѕynth | ||
being = music.legacy.Being() | ||
# 1) start a synth | ||
being = Being() | ||
|
||
# 2) set its parameters using sequences to be iterated through | ||
being.d_ = [1/2, 1/4, 1/4] # durations in seconds | ||
being.fv_ = [0, 1,5,15,150,1500,15000] # vibrato frequency | ||
being.fv_ = [0, 1, 5, 15, 150, 1500, 15000] # vibrato frequency | ||
being.nu_ = [5] # vibrato depth in semitones (maximum deviation of pitch) | ||
being.f_ = [220, 330] # frequencies for the notes | ||
|
||
# 3) render the wavfile | ||
being.render(30, 'thirty_notes.wav') # render 30 notes iterating though the lists above | ||
# 3) render the wavfile with 30 notes iterating though the lists above | ||
being.render(30, 'thirty_notes.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import music | ||
from music.legacy import Being | ||
from music.utils import horizontal_stack | ||
from music.core.io import write_wav_stereo | ||
|
||
# 1) start a ѕynth | ||
being = music.legacy.Being() | ||
|
||
# 2) set its parameters using sequences to be iterated through | ||
being.d_ = [1/2, 1/4, 1/4] # durations in seconds | ||
being.fv_ = [0, 1,5,15,150,1500,15000] # vibrato frequency | ||
being.nu_ = [5] # vibrato depth in semitones (maximum deviation of pitch) | ||
being.f_ = [220, 330] # frequencies for the notes | ||
being = Being() | ||
|
||
# 3) Use numpy arrays directly and use them to concatenate and/or mix sounds: | ||
s1 = being.render(30) | ||
being.f_ += [440] | ||
being.fv_ = [1,2,3,4,5] | ||
being.fv_ = [1, 2, 3, 4, 5] | ||
s2 = being.render(30) | ||
|
||
# s1 then s2 then s1 and s2 at the same time, then at the same time but one in each LR channel, | ||
# then s1 times s2 reversed, then s1+s2 but jumping 6 samples before using one: | ||
s3 = music.utils.horizontal_stack(s1, s2, s1 + s2, (s1, s2), | ||
s1*s2[::-1], | ||
s1[::7] + s2[::7]) | ||
music.core.io.write_wav_stereo(s3, 'thirty_numpy_notes.wav') | ||
# s1 then s2 then s1 and s2 at the same time, then at the same time but one in | ||
# each LR channel, then s1 times s2 reversed, then s1+s2 but jumping 6 samples | ||
# before using one: | ||
s3 = horizontal_stack(s1, s2, s1 + s2, (s1, s2), s1*s2[::-1], s1[::7] + | ||
s2[::7]) | ||
write_wav_stereo(s3, 'thirty_numpy_notes.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters