示例#1
0
# 2nd string settings
my_guitar.strings[1].tension = 20.5  # more tension
my_guitar.strings[1].length = 0.5  # short string (1 metre)
my_guitar.strings[1].radius = 0.0001  # thinner

# export the file as a format compatible instrument file for the NESS model
my_guitar.write("ness_files_to_process/inst_4_instrument.m")

#________________________________________
#_____CREATE THE SCORE FILE______________

# in order to test our instrument file, we create a quick score file that will play all the strings from 1 to [stringCount]
T = 9  # how long should the piece be (in seconds)?

# Create a score object, specifying the total duration (T) and the string count (numberOfStrings)
my_score = guitar.GuitarScore(T, stringCount)

# here we create a plucking sequence where each string is plucked in turn, until we are 4 seconds from the end of the score
# the pluck rate is the gap between plucks (in seconds)
pluckRate = 0.333
t = 0.1
i = 0
while t < (T - 4):
    s = i % stringCount
    my_score.pluck(s + 1, t)
    i += 1
    t += pluckRate

# explort the score as a NESS-compatible score file
my_score.write("ness_files_to_process/inst_4_score.m")
# Working with fingers and frets
# GuitarScore.playFret() function
# (1) specify string num, time, and fret number
# (2) additionally specify the glide time and finger force
# *************************************

# Global Parameters
numberOfStrings = 1         # how many strings should the guitar have?
T = 8                      # how long should the piece be (in seconds)?


#________________________________________
#_____CREATE THE SCORE FILE_________

# Create a score object, specifying the total duration (T) and the string count (numberOfStrings)
my_score = guitar.GuitarScore(T, numberOfStrings)       

# Here we use the playFret function to assign a finger to a fret at a particular time
# The finger is placed slightly behind the actual fret

#					string num, time, fret_num
my_score.playFret		(1, 	0.2,   	2)		# this says to move a finger on string 1 to fret 2 at 1 second
my_score.playFret		(1, 	0.5,   	7)		# this says to move a finger on string 1 to fret 7 at 3 seconds

#add another pluck with some extra parameters for glide time and finger force
#					string num, time (s), fret_num   glide time (s)		finger force (Newtons - onto string)
my_score.playFret		(1, 	2, 			4,  		0.1,			0.5)			
my_score.playFret		(1, 	3, 			2, 			1.9, 			8)				

# explort the score as a NESS-compatible score file
my_score.write("ness_files_to_process/gtr_score_3.m")
示例#3
0
from nesstools import guitar

#________________________________________
# General variables
# note that we don't need to define the score duration, T, here, as that will be determined by the tab
numberOfStrings = 6         # how many strings should the guitar have?


#________________________________________
#_____CREATE THE SCORE FILE_________

# Note that because we are using tab to create the score, the initial T is arbitrary, as it will be determined later, 
# but a value for T still needs to be specified (0 in this example)
my_score = guitar.GuitarScore(0, numberOfStrings)       

# specify the tab file as a list of strings, one element for each string
# here, each string is set up as s1, s2, ... s6, where s1 is the thicker E string and s6 us the thinnest string

s6 = "|-0------0--2--3-3-----|"
s5 = "|-0-----0-------3------|"
s4 = "|-0----0---------4-----|"
s3 = "|-2---2-----------5----|"
s2 = "|-2--2-----------5-----|"
s1 = "|-0-0----------3---3---|"
# collate the strings into a list
tab = [s1, s2, s3, s4, s5, s6]

# specify the playback rate for this tab.
# where a value of 1 is 1/8 of a second per unit, 2 is 1/16 of a second per unit, 0.5 is 1/4 of a second per unit, etc
rate = 0.5