guitarsounds: A Python package to visualize harmonic sounds for musical instrument design

The guitarsounds Python package can be used to efficiently visualize relevant features of harmonic sounds and is mainly developed to compare musical instrument design iterations. guitarsounds is wrapped around the implementation of common signal processing features, which are mainly taken from numpy (

The guitarsounds package is divided in two main components.First, the package is developed around a convenient object-oriented Application Programming Interface (API) that can be used to extract features from sounds and visualize them according to the user's needs.Then, a graphical user interface (GUI) makes most of the features of guitarsounds available to users less knowledgeable in programming.guitarsounds is meant to be used with the Jupyter Notebook interface to allow interactively exploring the sound data, either with the API or the GUI.
The main features of guitarsounds are to: • Automate the loading, conditioning and normalization of multiple sound files to meaningfully compare their features.• Visualize sounds features relevant to musical instrument design, such as: -Linear and logarithmic time envelope -Octave bands Fourier transform -Time-dependent damping • Divide sounds in frequency bands to analyze variations in temporal behaviour for different frequency ranges.• Extract the Fourier transform peaks of a harmonic signal using a custom peak finding algorithm.• Extract numerical values for certain features such as the Helmholtz cavity frequency of a guitar.• Provide an easy-to-use signal processing API to compute new features meeting specific needs by providing access to lower level features and handling the differences between sound files, such as the file sample rate.
Specifically, the API provides four classes nested together: • Plot: Provides low level plotting of specific features, such as plotting the Fast Fourier Transform (FFT) of a sound file.• Signal: Stores the data of an array corresponding to a single signal.For example, if a sound file is read and filtered, the array resulting from the filtering operation will be file is read using guitarsounds, all the processing is handled by the Sound class, such as truncating, filtering, or normalizing the sound signal.The Sound class provides the features relying on more than one Signal instance, but still using the information from a single sound file, such as the power distribution of a sound across different frequency bands.• Contains multiple Sound class instances and provides the features used to compare the data between different sound files.The SoundPack methods are divided between methods developed to compare two sounds and methods developed to compare an arbitrary amount of sounds.As an example, the method plotting the FFT of two sounds in a mirror configuration can only be called if the SoundPack was constructed using exactly two sounds, whereas the method showing a table of the different sound fundamental frequencies can be called for a SoundPack instance created using an arbitrary number of Sounds.
To illustrate the use of guitarsounds, the log-time envelope, a feature representing the amplitude of a sound with a higher definition in time at the start of the sound, can be computed using guitarsounds.By plotting this feature for the same note played on two instruments, the dynamic response of the instruments can be compared for a specific excitation frequency.A code snippet comparing the log-time envelope of two sounds is presented below with the associated output in Figure 1.In the following code, the SoundPack object is first instantiated from the specified sound files.For each file, a Sound class instance is created and conditioned.In the conditioning procedure, the signal is first resampled to have a sample rate equal to 22050 Hz.This is important to ensure all the features compared between sounds are computed using the same sample rate.The sound is then trimmed so that the beginning of the onset is at 100 ms, as can be seen on Figure 1.To ensure compared sounds have the same length, the ends of the sounds are trimmed so that each sound has the same number of samples as the shortest sound.The guitarsounds package relies on matplotlib (Hunter, 2007) for all its vizualisation features.Thus, users familiar with matplotlib objects can tune the figures created by guitarsounds to their needs.

Statement of need
guitarsounds was developed to meet the needs of the Bruand lutherie school, more precisely as a tool to visualize and compare the sounds of different guitar designs using custom sound features.The guitarsounds package was used in previous academic work (in press) to investigate the difference between two guitars both designed using an innovative numerical prototyping method based on topological optimization.In the scope of this research, guitarsounds allowed the measurement of specific sound features such as the slope of the peaks in the signal Fourier transform, computed using a linear regression.This feature is related to the instrument's tone (Sumi & Ono, 2008), and was used to study the differences between the two guitar designs.
guitarsounds is also used in ongoing research at the Bruand lutherie school to manage sound data in a project where guitar sounds are generated with random values for specific features, to provide data for a psycho-acoustic study.The guitarsounds API is also used to give an introduction to programming for data analysis to the school's students and in the teaching activities, as a tool to visualize the physical phenomena involved in the sounds produced by guitars, such as the Helmholtz cavity frequency of an instrument.The GUI was included in the package as knowledge or interest in programming isn't expected in the luthier's training.
A screen capture of the GUI is shown in Figure 2.
The features of guitarsounds differ from those of existing packages in their ability to be both used alone to produce decent figures with a minimal number of lines of code and as a tool in a Python data visualization stack where the sound specific needs can be handled by guitarsounds.There exists an overlap between guitarsounds and the librosa (McFee et al., 2015) Python package for music analysis; however, librosa is not a dependency of guitarsounds, and the latter is more focused on feature extraction for machine learning applications and lacks features tailored to harmonic sound analysis and integrated comparison of sounds.The librosa package is also aimed at an audience with a more developed knowledge of Python programming.
stored in a new instance of the Signal class.An instance of the Plot class is constructed for each Signal class instance and stored as an attribute of the Signal class.The Signal class contains all the features relying only on the data of a single sound signal, such as the computation of the envelope.• Sound: Stores all the information corresponding to a single sound file.When a .wav

Figure 1 :
Figure 1: Output of the code snippet comparing the log-time envelope of two sounds.

Figure 2 :
Figure 2: Graphical user interface in the Jupyter Notebook environment.