Ejemplo n.º 1
0
def getVoices(input):
    # return list of voices from string input

    # find number of voices
    nv = countString("voice:", input)

    # normalize input
    if nv == 0:
        nv = 1
        input = "voice:1 " + input

    # put first nv - 1 voices in list "voices"
    voices = []
    for i in range(0, nv - 1):
        begin = "voice:" + ` i + 1 `
        end = "voice:" + ` i + 2 `
        voice = getChunk(input, begin, end)
        k = input.find(end)
        input = input[k:]
        voices.append(voice)
    begin = "voice:" + ` nv `
    k = len(begin)
    voices.append(input[k:])

    # return list
    # print "VOICES:", voices
    return voices

    print voices
Ejemplo n.º 2
0
def getVoices(input):
  # return list of voices from string input

  # find number of voices
  nv = countString("voice:", input)
  
  # normalize input
  if nv == 0:
    nv = 1
    input = "voice:1 "+input
    
  # put first nv - 1 voices in list "voices"  
  voices = [ ]
  for i in range(0,nv-1):
    begin = "voice:"+`i+1`
    end = "voice:"+`i+2`
    voice = getChunk(input, begin, end)
    k = input.find(end)
    input = input[k:]
    voices.append(voice)
  begin = "voice:"+`nv`
  k = len(begin)
  voices.append(input[k:])

  # return list
  # print "VOICES:", voices
  return voices
   
  print voices
Ejemplo n.º 3
0
def run(input, fileName, SCALE):

    global waveformFiles, voiceProcessed, durations
    print

    # set up file names
    F = fileName.split(".")[0]
    # quadFile = F+".quad"
    # sampFile = F+".samp"
    wavFile = F + ".wav"
    # print "FILES:", quadFile, sampFile, wavFile

    # input = executePreamble(input)

    # extract the voices (return list thereof)
    voices = getVoices(input)

    voiceProcessed = 0
    waveformFiles = []
    durations = []

    # process Voices
    voiceProcessed = 0
    for voice in voices:
        global maximumAmplitude
        # HERE IS THE ACTION:
        thisMaximumAmplitude = processVoice(voice, SCALE)
        if thisMaximumAmplitude > maximumAmplitude:
            maximumAmplitude = thisMaximumAmplitude
        voiceProcessed = voiceProcessed + 1

    # mix waveform files if necessary
    if voiceProcessed > 1:
        print "Mixing ..."
        mixfile = "tmp-mix.samp"
        cmd = catList([MIX] + [mixfile, "> tmp-val"])
        os.system(cmd)
        value = getChunk(file2string("tmp-val"), "<maximumAmplitude>",
                         "</maximumAmplitude>")
        maximumAmplitude = float(value)
        print "mix, maximum amplitude:", maximumAmplitude

    # generate waveform file
    print "generating audio file ..."
    if voiceProcessed == 1:
        sampFile = "tmp0.samp"
        samp2wav(sampFile, wavFile)
    else:
        samp2wav(mixfile, wavFile)

    print "run, maximum amplitude:", maximumAmplitude

    if CLEANUP == ON:
        cmd = "rm tmp*.quad tmp*.samp"
        os.system(cmd)
Ejemplo n.º 4
0
def run(input, fileName, SCALE):
  
  global waveformFiles, voiceProcessed, durations
  print
  
  # set up file names
  F = fileName.split(".")[0]
  # quadFile = F+".quad"
  # sampFile = F+".samp"
  wavFile = F+".wav"
  # print "FILES:", quadFile, sampFile, wavFile
    
  # input = executePreamble(input)
  
  # extract the voices (return list thereof)
  voices = getVoices(input)
  
  voiceProcessed = 0
  waveformFiles = [ ]
  durations = [ ]
  
  # process Voices
  voiceProcessed = 0
  for voice in voices:
    global maximumAmplitude
    # HERE IS THE ACTION:
    thisMaximumAmplitude = processVoice(voice, SCALE)
    if thisMaximumAmplitude > maximumAmplitude:
      maximumAmplitude = thisMaximumAmplitude	
    voiceProcessed = voiceProcessed + 1
  
  # mix waveform files if necessary
  if voiceProcessed > 1:
    print "Mixing ..."
    mixfile = "tmp-mix.samp"
    cmd = catList([MIX] + [mixfile, "> tmp-val"]) 
    os.system(cmd)
    value = getChunk(file2string("tmp-val"), "<maximumAmplitude>", "</maximumAmplitude>")
    maximumAmplitude = float(value)
    print "mix, maximum amplitude:", maximumAmplitude
  
  # generate waveform file
  print "generating audio file ..."
  if voiceProcessed == 1:
    sampFile = "tmp0.samp"
    samp2wav(sampFile, wavFile)
  else:
    samp2wav(mixfile, wavFile)
    
  print "run, maximum amplitude:", maximumAmplitude
  
  if CLEANUP == ON:
    cmd = "rm tmp*.quad tmp*.samp"
    os.system(cmd)
Ejemplo n.º 5
0
def quad2samp (inputFile, outputFile):

  global QUAD2SAMP
  # run the command 
  #
  #    quad <inputFile> <outputFile>
  #
  # to create a wave sample file from
  # a *.quad file

  cmd = catList([QUAD2SAMP, inputFile, outputFile, ">tmp-val"])
  # cmd = catList([QUAD2SAMP, inputFile, outputFile])
  os.system(cmd)
  value = getChunk(file2string("tmp-val"), "<maximumAmplitude>", "</maximumAmplitude>")
  maximumAmplitude = float(value);
  print "quad2samp, maximum amplitude:", maximumAmplitude
  return maximumAmplitude
Ejemplo n.º 6
0
def quad2samp(inputFile, outputFile):

    global QUAD2SAMP
    # run the command
    #
    #    quad <inputFile> <outputFile>
    #
    # to create a wave sample file from
    # a *.quad file

    cmd = catList([QUAD2SAMP, inputFile, outputFile, ">tmp-val"])
    # cmd = catList([QUAD2SAMP, inputFile, outputFile])
    os.system(cmd)
    value = getChunk(file2string("tmp-val"), "<maximumAmplitude>",
                     "</maximumAmplitude>")
    maximumAmplitude = float(value)
    print "quad2samp, maximum amplitude:", maximumAmplitude
    return maximumAmplitude