Skip to content
47 changes: 36 additions & 11 deletions examples/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,42 @@
_wav.extend(list(wave))


# export tube sections
tube_length_cm = (ctypes.c_double * 40)()
tube_area_cm2 = (ctypes.c_double * 40)()
tube_articulator = (ctypes.c_int * 40)()
incisor_pos_cm = ctypes.c_double(0)
tongue_tip_side_elevation = ctypes.c_double(0)
velum_opening_cm2 = ctypes.c_double(0)

VTL.vtlTractToTube(ctypes.byref(params_a),
ctypes.byref(tube_length_cm),
ctypes.byref(tube_area_cm2),
ctypes.byref(tube_articulator),
ctypes.byref(incisor_pos_cm),
ctypes.byref(tongue_tip_side_elevation),
ctypes.byref(velum_opening_cm2))

# from Tube.h
ARTICULATOR = {0: 'vocal folds',
1: 'tongue',
2: 'lower incisors',
3: 'lower lip',
4: 'other articulator',
5: 'num articulators',
}

arti = [ARTICULATOR[sec] for sec in list(tube_articulator)]

if plt is not None and np is not None:
plt.plot(np.cumsum(tube_length_cm), tube_area_cm2, ds='steps')
plt.xlabel('tube section [cm]')
plt.ylabel('tube area [cm^2]')
for ii, x_pos in enumerate(np.cumsum(tube_length_cm)):
plt.text(x_pos, 1 + 0.3 * (ii % 2), arti[ii], rotation='vertical', fontsize='small')
plt.show()


# destroy current state of VTL and free memory
VTL.vtlClose()

Expand Down Expand Up @@ -237,14 +273,3 @@
print('scipy not available')
print('skip writing out wav file')

# Plot the area function of the first and the last frame.
# TODO
# Matlab code:
#figure;
#plot(1:1:numTubeSections, tubeAreas(1:numTubeSections), ...
# 1:1:numTubeSections,
# tubeAreas(1+(numFrames-1)*numTubeSections:(numFrames-1)*numTubeSections +
# numTubeSections));
#xlabel('Position in cm');
#ylabel('Tube section index');

4 changes: 3 additions & 1 deletion examples/example6.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
# change the `convert_directory.py` to your liking and then execute it on the
# Terminal with blender
if sys.platform.startswith('win32'):
os.system(r'"D:\Program Files\Blender Foundation\Blender 3.0\blender.exe" --background --python Meshes/convert_directory.py')
command = r'"D:\Program Files\Blender Foundation\Blender 3.0\blender.exe" --background --python Meshes/convert_directory.py'
print(f"check that the following command points to the right Blender installation (if not change the line in example6.py):\n\n{command}")
os.system(command)
else:
os.system('blender --background --python Meshes/convert_directory.py 1> /dev/null')

Expand Down