def test_N(violin, N, inst, st):
    violin.reset()
    pc = violin.get_physical_constants(st)
    pc.N = N
    violin.set_physical_constants(st, pc)
    seconds = 5.0
    num_samples = int(seconds*44100.0)
    violin.pluck(st, 0.47, 4.0)
    wavfile = monowav.MonoWav(
        str("out/pluck-modes-%i-%i-%i.wav" % (inst, st, N)))
    buf = wavfile.request_fill(num_samples)
    artifastring_instrument.wait_samples_c(violin, buf, num_samples)
Example #2
0
def test_N(violin, N, inst, st):
    violin.reset()
    pc = violin.get_physical_constants(st)
    pc.N = N
    violin.set_physical_constants(st, pc)
    seconds = 5.0
    num_samples = int(seconds * 44100.0)
    violin.pluck(st, 0.47, 4.0)
    wavfile = monowav.MonoWav(
        str("out/pluck-modes-%i-%i-%i.wav" % (inst, st, N)))
    buf = wavfile.request_fill(num_samples)
    artifastring_instrument.wait_samples_c(violin, buf, num_samples)
Example #3
0
def parseFile(lines, wavfile):
    violin = artifastring_instrument.ArtifastringInstrument()
    total_samples = 0

    for i, line in enumerate(lines):
        # is a comment
        if (line[0] == '#'):
            continue
        splitline = line.split()

        # advance time
        action_time = float( splitline[1] )
        delta_samples = artifastring_instrument.ARTIFASTRING_INSTRUMENT_SAMPLE_RATE*action_time - total_samples
        delta_samples = int(delta_samples)
        if delta_samples > 0:
#            print "advancing", delta_samples, "samples"
            buf = wavfile.request_fill(delta_samples)
            artifastring_instrument.wait_samples_c(violin, buf, delta_samples)
            total_samples += delta_samples
        elif delta_samples == 0:
            pass
        else:
            print "ERROR: move backwards in time? line", i
        actions(violin,splitline)
Example #4
0
def parseFile(lines, wavfile):
    violin = artifastring_instrument.ArtifastringInstrument()
    total_samples = 0

    for i, line in enumerate(lines):
        # is a comment
        if (line[0] == '#'):
            continue
        splitline = line.split()

        # advance time
        action_time = float(splitline[1])
        delta_samples = artifastring_instrument.ARTIFASTRING_INSTRUMENT_SAMPLE_RATE * action_time - total_samples
        delta_samples = int(delta_samples)
        if delta_samples > 0:
            #            print "advancing", delta_samples, "samples"
            buf = wavfile.request_fill(delta_samples)
            artifastring_instrument.wait_samples_c(violin, buf, delta_samples)
            total_samples += delta_samples
        elif delta_samples == 0:
            pass
        else:
            print "ERROR: move backwards in time? line", i
        actions(violin, splitline)
 def test_stable(self, st, beta, bow_force, vb):
     self.vln.reset()
     wavfile = monowav.MonoWav("pc-consts/test-stable.wav")
     for i in range(
             int(TEST_SECONDS *
                 artifastring_instrument.ARTIFASTRING_INSTRUMENT_SAMPLE_RATE
                 / HOPSIZE)):
         self.vln.finger(st, 0.251, 1.0)
         self.vln.bow(st, beta, bow_force, vb)
         buf = wavfile.request_fill(HOPSIZE)
         #stable = self.vln.wait_samples(self.audio_out_buf)
         stable = artifastring_instrument.wait_samples_c(
             self.vln, buf, HOPSIZE)
         #print stable
         if stable > 0:
             print stable
             print "bail stable 1"
             print bow_force
             #exit(1)
             return False
         #self.vln.wait_samples_forces(self.audio_out_buf,
         #    self.force_out_buf, HOPSIZE)
         #if not stable:
         #    return False
     #print 'ok'
     #exit(1)
     stable = self.vln.wait_samples(self.audio_out_buf)
     #print stable
     if stable > 0:
         print "bail stable 2"
         return False
     #self.vln.wait_samples_forces(self.audio_out_buf,
     #   self.force_out_buf, HOPSIZE)
     #if not stable:
     #   return False
     #flatness = self.spectral_flatness(self.audio_out_buf)
     #force_ok = self.spectral_forces(self.force_out_buf)
     #if not flatness:
     #    print "bail flatness 1"
     #    return False
     #print flatness
     #if flatness > MAX_SPECTRAL_FLATNESS:
     #    print "bail flatness 2"
     #    return False
     return True
Example #6
0
 def test_stable(self, st, beta, bow_force, vb):
     self.vln.reset()
     wavfile = monowav.MonoWav("pc-consts/test-stable.wav")
     for i in range(int(TEST_SECONDS * artifastring_instrument.ARTIFASTRING_INSTRUMENT_SAMPLE_RATE / HOPSIZE)):
         self.vln.finger(st, 0.251, 1.0)
         self.vln.bow(st, beta, bow_force, vb)
         buf = wavfile.request_fill(HOPSIZE)
         # stable = self.vln.wait_samples(self.audio_out_buf)
         stable = artifastring_instrument.wait_samples_c(self.vln, buf, HOPSIZE)
         # print stable
         if stable > 0:
             print stable
             print "bail stable 1"
             print bow_force
             # exit(1)
             return False
         # self.vln.wait_samples_forces(self.audio_out_buf,
         #    self.force_out_buf, HOPSIZE)
         # if not stable:
         #    return False
     # print 'ok'
     # exit(1)
     stable = self.vln.wait_samples(self.audio_out_buf)
     # print stable
     if stable > 0:
         print "bail stable 2"
         return False
     # self.vln.wait_samples_forces(self.audio_out_buf,
     #   self.force_out_buf, HOPSIZE)
     # if not stable:
     #   return False
     # flatness = self.spectral_flatness(self.audio_out_buf)
     # force_ok = self.spectral_forces(self.force_out_buf)
     # if not flatness:
     #    print "bail flatness 1"
     #    return False
     # print flatness
     # if flatness > MAX_SPECTRAL_FLATNESS:
     #    print "bail flatness 2"
     #    return False
     return True