Skip to content

Latest commit

 

History

History
214 lines (144 loc) · 7.14 KB

index.rst

File metadata and controls

214 lines (144 loc) · 7.14 KB

Py Guiter Synthesizer

Welcome to the py_guitar_synth project documentation! This project focuses on synthesizing realistic guitar sounds based on guitar tab sheets, simulating the physical and musical characteristics of strings and performance techniques.

py_guitar_synth Logo

py_guitar_synth translates guitar tab notation into audio, allowing users to generate guitar sounds by defining the instrument's physical characteristics, plucking techniques, and processing effects like convolution and echo. The generated sound is synthesized by modeling string vibrations, transitions, and harmonic properties.

To install the project, clone the repository and install the required dependencies:

git clone https://github.com/yourusername/py_guitar_synth.git
cd py_guitar_synth
pip install -r requirements.txt

You can also install it as a package by running:

pip install .

The guitar tab sheets used in this project follow a specific syntax to define frets, notes, and other musical elements. Here’s a breakdown of the syntax:

Each string is represented by a line with the corresponding string name: - e: High E string - B: B string - G: G string - D: D string - A: A string - E: Low E string

Example:

e|-3---|
B|-----|
G|-----|
D|-----|
A|-----|
E|-----|

This example shows that the third fret on the high e string is played.

Numbers represent the frets, while letters a to f are used for frets 10-15:

e|--a---3--|  # Fret 10 on high E, fret 3 next

Symbols are used to represent note durations: - !: Eighth note (NoteValue.eighthNote) - !!: Sixteenth note (NoteValue.sixteenthNote) - +: Half note (NoteValue.halfNote) - ++: Whole note (NoteValue.wholeNote) - No symbol: Defaults to a quarter note (NoteValue.quarterNote)

Example:

e|-3+---3!!--|  # Half note followed by a sixteenth note

To indicate that a note should sustain beyond its nominal duration, the letter r is used:

e|-3r--|

Notes played simultaneously across different strings can be written in a vertical column:

e|-3--|
B|-0--|
G|-0--|

This represents an E minor chord.

A chord can also be played while the hand is gradually plucking the strings, resulting in a technique known as arpeggiation or a rolled chord. This technique involves plucking each string in quick succession rather than striking all the strings at once. In the following example, the "r" symbol indicates that each note should "let ring," meaning the string should continue to resonate after being plucked.

e |----------------------3++r-|
B |------------------3!!r-----|
G |--------------0!!r---------|
D |----------0!!r-------------|
A |-----2!!r------------------|
E |-3!!r----------------------|

This notation represents a G major chord, but instead of strumming all the strings simultaneously, the player gradually plucks each string, starting from the low E string to the high e string. As each note is played, the previous ones continue to resonate due to the "r" (letRing=True), allowing for a smooth, cascading effect as the chord is built up across the strings.

The numbers represent the frets, while the symbols (e.g., ++, !!) indicate the duration of each note, from longer whole notes (++) to shorter sixteenth notes (!!). This rolling technique creates a more textured and dynamic sound, often used in classical and fingerstyle guitar playing.

For advanced users seeking to define their own instruments, a custom JSON structure can be created, which captures the nuanced characteristics of the instrument’s strings, vibrato, harmonic richness, and decay profiles.

The key parameters include:

  • `supports_transitions`: Whether the instrument supports glissando and legato transitions, crucial for smooth melodic contouring.
  • `supports_vibrato`: Defines the presence of vibrato, an essential feature for enhancing tonal expressivity through periodic modulation.

Each string has the following parameters, enabling the user to model complex acoustic phenomena:

  • `base_frequency`: The fundamental pitch (Hz) of the string. This directly affects the modal frequencies of the vibrating string.
  • `inharmonicity_coefficient`: A value controlling the degree of inharmonicity—deviation from pure harmonic frequencies due to stiffness or non-linearity.
  • `vibrato_frequency`: Frequency of the vibrato modulation, enhancing the periodic tonal fluctuation.
  • `vibrato_amplitude`: The depth of the vibrato, determining the extent of pitch variation.
  • `attack_duration`: How quickly the sound reaches its maximum amplitude, defined in milliseconds (ms). Shorter durations are characteristic of sharp attacks.
  • `max_duration`: The maximum sustain of the note before decay, critical for long tones.
  • `dynamic_range_factor`: Modulates the intensity of sound based on the plucking force, simulating the physical interaction of the player.
  • `decay_rates`: Defines the multi-phase decay envelope of the note. Fast, mid, and slow decay rates determine the sound's evolution over time.
  • `harmonics_weights`: Controls the amplitude of harmonics in the frequency spectrum, contributing to the timbral identity of the instrument.

Creating a custom instrument allows for the synthesis of any stringed instrument, modeled using these principles of acoustics and digital sound synthesis.

Below are the key modules that make up the py_guitar_synth project.

.. toctree::
   :maxdepth: 2

   py_guitar_synth/instruments
   py_guitar_synth/sheets
   py_guitar_synth/tab_parser
   py_guitar_synth/signal_processing
   py_guitar_synth/types
   py_guitar_synth/instrument_parser

Here is a simple usage example demonstrating how to synthesize a guitar sequence:

from py_guitar_synth import default_classical_guitar, law_bass_f_aini, generate_guitar_signal_from_sheet
import sounddevice as sd

# Generate the guitar signal from a sheet
signal = generate_guitar_signal_from_sheet(
    instrument=default_classical_guitar,
    sheet=law_bass_f_aini
)

# Play the generated sound
sd.play(signal, 44100)
sd.wait()

You can customize the instrument, apply effects such as convolution with impulse responses, and even add echo to simulate room acoustics.

We welcome contributions! Feel free to submit pull requests, report issues, or suggest improvements. Please make sure to follow the contribution guidelines provided in the repository.

This project is licensed under the MIT License.

Mustafa Alotbah Email: mustafa.alotbah@gmail.com