def unpitched_high(dur, idx):
  """
  Non-harmonic treble/higher frequency sound as a list (due to memoization).

  Parameters
  ----------
  dur:
    Duration, in samples.
  idx:
    Zero or one (integer), for a small difference to the sound played.

  Returns
  -------
  A list with the synthesized note.

  """
  first_dur, a, d, r, gain = [
    (30 * ms, 10 * ms, 8 * ms, 10 * ms, .4),
    (60 * ms, 20 * ms, 8 * ms, 20 * ms, .5)
  ][idx]
  env = chain(adsr(first_dur, a=a, d=d, s=.2, r=r),
              adsr(dur - first_dur,
                   a=10 * ms, d=30 * ms, s=.2, r=dur - 50 * ms))
  result = gauss_noise(dur) * env * gain
  return list(result)
def unpitched_high(dur, idx):
  """
  Non-harmonic treble/higher frequency sound as a list (due to memoization).

  Parameters
  ----------
  dur:
    Duration, in samples.
  idx:
    Zero or one (integer), for a small difference to the sound played.

  Returns
  -------
  A list with the synthesized note.

  """
  first_dur, a, d, r, gain = [
    (30 * ms, 10 * ms, 8 * ms, 10 * ms, .4),
    (60 * ms, 20 * ms, 8 * ms, 20 * ms, .5)
  ][idx]
  env = chain(adsr(first_dur, a=a, d=d, s=.2, r=r),
              adsr(dur - first_dur,
                   a=10 * ms, d=30 * ms, s=.2, r=dur - 50 * ms))
  result = gauss_noise(dur) * env * gain
  return list(result)
示例#3
0
s, Hz = sHz(rate)
ms = 1e-3 * s
kHz = 1e3 * Hz
beat_duration = 60. / beat * s # In samples
dur = beat_duration / notes_per_beat # Per note
smix = Streamix() # That's our sound mixture
env = adsr(dur, a=40*ms, d=35*ms, s=.6, r=70*ms).take(inf) # Envelope

# Effects used
def distortion(sig, multiplier=18):
  return atan(multiplier * sig) * (2 / pi)

# Intro count synth
filt = (1 - z ** -2) * .5
if starting_beats > 0:
  inoisy_stream = filt(gauss_noise()) * env
  inoisy_thub = thub(inoisy_stream.append(0).limit(beat_duration),
                     starting_beats)
  inoisy = chain.from_iterable(repeat(inoisy_thub).limit(starting_beats))
  smix.add(.1 * s, inoisy)
  smix.add(starting_beats * beat_duration - dur, []) # Event timing

# Wavetable lookup initialization
square_table = TableLookup([1] * 256 + [-1] * 256)
harmonics = dict(enumerate([1, 3, 2, 1, .3, .1, .7, .9, 1, 1, .5, .4, .2], 1))
table = sin_table.harmonize(harmonics).normalize()
mem_table = (3 * saw_table + (sin_table - saw_table) ** 3).normalize()

# Notes synth
midi_tuning = str2midi([gs.tune for gs in guitar])
midi_pitches = [midi_tuning[string_idx] + fret for string_idx, fret in notes]
示例#4
0
kHz = 1e3 * Hz
beat_duration = 60. / beat * s  # In samples
dur = beat_duration / notes_per_beat  # Per note
smix = Streamix()  # That's our sound mixture
env = adsr(dur, a=40 * ms, d=35 * ms, s=.6, r=70 * ms).take(inf)  # Envelope


# Effects used
def distortion(sig, multiplier=18):
    return atan(multiplier * sig) * (2 / pi)


# Intro count synth
filt = (1 - z**-2) * .5
if starting_beats > 0:
    inoisy_stream = filt(gauss_noise()) * env
    inoisy_thub = thub(
        inoisy_stream.append(0).limit(beat_duration), starting_beats)
    inoisy = chain.from_iterable(repeat(inoisy_thub).limit(starting_beats))
    smix.add(.1 * s, inoisy)
    smix.add(starting_beats * beat_duration - dur, [])  # Event timing

# Wavetable lookup initialization
square_table = TableLookup([1] * 256 + [-1] * 256)
harmonics = dict(enumerate([1, 3, 2, 1, .3, .1, .7, .9, 1, 1, .5, .4, .2], 1))
table = sin_table.harmonize(harmonics).normalize()
mem_table = (3 * saw_table + (sin_table - saw_table)**3).normalize()

# Notes synth
midi_tuning = str2midi([gs.tune for gs in guitar])
midi_pitches = [midi_tuning[string_idx] + fret for string_idx, fret in notes]