Line 8: Line 8:
  
 
The Karplus-Strong algorithm uses a noise burst as an initial condition, a filter of the designer's choice, and a positive feedback loop to produce a signal that sounds similar to a note being played on a guitar:
 
The Karplus-Strong algorithm uses a noise burst as an initial condition, a filter of the designer's choice, and a positive feedback loop to produce a signal that sounds similar to a note being played on a guitar:
* Initial Condition: The initial input to the algorithm is a signal with length L. This corresponds to the input of energy when a guitar string is plucked. The examples at the bottom of the article show what happens to the output when random white noise, a cycle of a sawtooth wave, and a cycle of a square wave are chosen as the initial condition for the algorithm.
+
* Initial Condition: The initial input to the algorithm is a signal with length L. This corresponds to the input of energy when a guitar string is plucked. The examples at the bottom of the article show what happens to the output when random white noise, a period of a sawtooth wave, and a period of a square wave are chosen as the initial condition for the algorithm.
* The Filter: The filter is another design decision that can be chosen. This corresponds to the atmosphere and friction acting to reduce energy from the string. Depending on the characteristics of the chosen filter, you can model more energy being taken from the lower frequencies on the string, or more energy being taken from the higher frequencies on the string. The examples at the bottom of the article show what happens to the output when a simple averaging filter is applied.
+
* The Filter: The filter is another design decision that can be chosen. This corresponds to the atmosphere and friction acting to reduce energy from the string. Depending on the characteristics of the chosen filter, you can model more energy being taken from the lower frequencies on the string, or more energy being taken from the higher frequencies on the string. The examples at the bottom of the article show what happens to the output when an IIR filter with poles near an A string's harmonic frequencies is chosen.
 
* The Feedback Loop: The feedback loop aspect of the algorithm is what puts all the pieces together to form the sound. The processed input is fed back into the loop to create the output signal. We didn't explicitly cover the stability of a feedback loop in 438, but it is still important to know that for this loop, the gain of the filter has to be less than 1 for any given input, for the entire system to remain stable. So, the frequency response of the filter from the previous bullet point should be less than 1 for any given frequency, to ensure the system is a stable positive feedback system.
 
* The Feedback Loop: The feedback loop aspect of the algorithm is what puts all the pieces together to form the sound. The processed input is fed back into the loop to create the output signal. We didn't explicitly cover the stability of a feedback loop in 438, but it is still important to know that for this loop, the gain of the filter has to be less than 1 for any given input, for the entire system to remain stable. So, the frequency response of the filter from the previous bullet point should be less than 1 for any given frequency, to ensure the system is a stable positive feedback system.
  
The output signal from this process will be a varied and random disturbance that gradually smooths out, which is a reasonably simple model of a plucked string. Here are some examples of the algorithm at work:
+
'''''Examples:'''''
 
+
The output signal from the above process will be a varied and random disturbance that gradually smooths out, which is a reasonably simple model of a plucked string. Here are some examples of the algorithm at work:
  
 
Example 1
 
Example 1
 +
[https://drive.google.com/file/d/1UotvgDt0l9muA63047gTthLWevtsHBC_/view?usp=sharing Random Input Signal]
  
 
Example 2
 
Example 2
 +
[https://drive.google.com/file/d/1DNRJPpzqRzUw2QsK5NyDODhZSRVarwG0/view?usp=sharing Sawtooth Cycle Input Signal]
  
 
Example 3
 
Example 3
 +
[https://drive.google.com/file/d/18jfz9CbdIpTk89dau4bi2GBRPQ4yE8e2/view?usp=sharing Square Cycle Input Signal]
 +
 +
As you can see, the random input signal sounds the most like a real-life guitar string. The sawtooth and square wave examples didn't sound like a normal guitar, but still sounded cool and could possibly be used in some other electronic music application!
 
   
 
   
  
Sources/Extra Info:
+
'''''Sources/Extra Info:'''''
 
https://en.wikipedia.org/wiki/Karplus%E2%80%93Strong_string_synthesis
 
https://en.wikipedia.org/wiki/Karplus%E2%80%93Strong_string_synthesis
 
https://ccrma.stanford.edu/~jos/pasp/Karplus_Strong_Algorithm.html
 
https://ccrma.stanford.edu/~jos/pasp/Karplus_Strong_Algorithm.html
 
http://sites.music.columbia.edu/cmc/MusicAndComputers/chapter4/04_09.php
 
http://sites.music.columbia.edu/cmc/MusicAndComputers/chapter4/04_09.php
 +
https://www.mathworks.com/help/signal/examples/generating-guitar-chords-using-the-karplus-strong-algorithm.html

Revision as of 22:42, 1 December 2019

Modeling the sound of an acoustic guitar using the Karplus-Strong algorithm


Introduction/Theory:

We spent some time in lecture modeling speech by analyzing a simplified physical model and deriving the corresponding transfer function. The same thing can be done for other types of sounds, both more complex and less complex than speech. The sound of a plucked string on a guitar is one such sound.

The Karplus-Strong algorithm uses a noise burst as an initial condition, a filter of the designer's choice, and a positive feedback loop to produce a signal that sounds similar to a note being played on a guitar:

  • Initial Condition: The initial input to the algorithm is a signal with length L. This corresponds to the input of energy when a guitar string is plucked. The examples at the bottom of the article show what happens to the output when random white noise, a period of a sawtooth wave, and a period of a square wave are chosen as the initial condition for the algorithm.
  • The Filter: The filter is another design decision that can be chosen. This corresponds to the atmosphere and friction acting to reduce energy from the string. Depending on the characteristics of the chosen filter, you can model more energy being taken from the lower frequencies on the string, or more energy being taken from the higher frequencies on the string. The examples at the bottom of the article show what happens to the output when an IIR filter with poles near an A string's harmonic frequencies is chosen.
  • The Feedback Loop: The feedback loop aspect of the algorithm is what puts all the pieces together to form the sound. The processed input is fed back into the loop to create the output signal. We didn't explicitly cover the stability of a feedback loop in 438, but it is still important to know that for this loop, the gain of the filter has to be less than 1 for any given input, for the entire system to remain stable. So, the frequency response of the filter from the previous bullet point should be less than 1 for any given frequency, to ensure the system is a stable positive feedback system.

Examples: The output signal from the above process will be a varied and random disturbance that gradually smooths out, which is a reasonably simple model of a plucked string. Here are some examples of the algorithm at work:

Example 1 Random Input Signal

Example 2 Sawtooth Cycle Input Signal

Example 3 Square Cycle Input Signal

As you can see, the random input signal sounds the most like a real-life guitar string. The sawtooth and square wave examples didn't sound like a normal guitar, but still sounded cool and could possibly be used in some other electronic music application!


Sources/Extra Info: https://en.wikipedia.org/wiki/Karplus%E2%80%93Strong_string_synthesis https://ccrma.stanford.edu/~jos/pasp/Karplus_Strong_Algorithm.html http://sites.music.columbia.edu/cmc/MusicAndComputers/chapter4/04_09.php https://www.mathworks.com/help/signal/examples/generating-guitar-chords-using-the-karplus-strong-algorithm.html

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett