<< Chapter < Page Chapter >> Page >

The screencast video continues the discussion by exploring the delay of the all-pass filter of as a function of the parameter C.

[video] Calculating the delay of the low pass filter

Implementing the pitch-accurate algorithm

Including the all-pass filter in the basic Karplus-Strong algorithm allows the loop time to be set to an arbitrary value, making it possible to sound a tone with any desired pitch.

This section guides you through the necessary steps to augment the basic algorithm with an all-pass filter, including the derivation of necessary equations to calculate the delay linelength and the fractional delay. Work through the derivations requested by each of the exercises.

To begin, the pitch of the output signal is the sampling frequency f S MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamOzamaaBaaaleaacaaIWaaabeaaaaa@370C@ divided by the total loop delay in samples:

f 0 = f S N + 1 2 + Δ MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamOzamaaBaaaleaacaaIWaaabeaakiabg2da9maalaaabaGaamOzamaaBaaaleaacaWGtbaabeaaaOqaaiaad6eacqGHRaWkdaWcaaqaaiaaigdaaeaacaaIYaaaaiabgUcaRiabfs5aebaaaaa@3FA9@

where Δ MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaeuiLdqeaaa@36A1@ is the fractional delay introduced by the all-pass filter.

Refer to . Derive a pair of equations that can be used to calculate the length of the delay line N MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamOtaaaa@360E@ and the value of the fractional delay Δ MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaeuiLdqeaaa@36A1@ .

N = f S f 0 1 2 MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamOtaiabg2da9maagmaabaWaaSaaaeaacaWGMbWaaSbaaSqaaiaadofaaeqaaaGcbaGaamOzamaaBaaaleaacaaIWaaabeaaaaGccqGHsisldaWcaaqaaiaaigdaaeaacaaIYaaaaaGaayj84laawUp+aaaa@4284@ (the "floor" operator converts the operand to an integer by selecting the largest integer that is less than the operand); Δ = f S f 0 N MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaeuiLdqKaeyypa0ZaaSaaaeaacaWGMbWaaSbaaSqaaiaadofaaeqaaaGcbaGaamOzamaaBaaaleaacaaIWaaabeaaaaGccqGHsislcaWGobaaaa@3D4B@

The all-pass filter delay can be approximated by (see Moore):

Δ = 1 C 1 + C MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaeuiLdqKaeyypa0ZaaSaaaeaacaaIXaGaeyOeI0Iaam4qaaqaaiaaigdacqGHRaWkcaWGdbaaaaaa@3C8C@

Refer to . Solve the equation for the all-pass filter coefficient C in terms of the required fractional delay.

C = 1 Δ 1 + Δ MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaam4qaiabg2da9maalaaabaGaaGymaiabgkHiTiabfs5aebqaaiaaigdacqGHRaWkcqqHuoaraaaaaa@3D2A@

The all-pass filter can be inserted at any point in the loop; shows the all-pass filter placed after the low pass filter.

Block diagram of the pitch-accurate Karplus-Strong algorithm

To simplify the derivation of the overall filter transfer function that relates y(n) to x(n), consider the three feedback elements (delay line, low pass filter, and all-pass filter) to be a single element with transfer function G ( z ) MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaam4raiaacIcacaWG6bGaaiykaaaa@385F@ . Derive the transfer function of the combined element.

The elements are in cascade, so the individual transfer functions multiply together: G ( z ) = z N H L P F ( z ) H A P F ( z ) MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaam4raiaacIcacaWG6bGaaiykaiabg2da9iaadQhadaahaaWcbeqaaiabgkHiTiaad6eaaaGccaWGibWaaSbaaSqaaiaadYeacaWGqbGaamOraaqabaGccaGGOaGaamOEaiaacMcacaWGibWaaSbaaSqaaiaadgeacaWGqbGaamOraaqabaGccaGGOaGaamOEaiaacMcaaaa@47E8@

Refer to the block diagram of . Considering that all three elements are represented by a single feedback element G(z), derive the overall transfer function H(z) for the digital filter in terms of G(z).

H ( z ) = 1 1 G ( z ) MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamisaiaacIcacaWG6bGaaiykaiabg2da9maalaaabaGaaGymaaqaaiaaigdacqGHsislcaWGhbGaaiikaiaadQhacaGGPaaaaaaa@3EFD@

Recall the low pass filter transfer function ( ):

H L P F ( z ) = g ( 1 + z 1 ) MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamisamaaBaaaleaacaWGmbGaamiuaiaadAeaaeqaaOGaaiikaiaadQhacaGGPaGaeyypa0Jaam4zaiaacIcacaaIXaGaey4kaSIaamOEamaaCaaaleqabaGaeyOeI0IaaGymaaaakiaacMcaaaa@42CD@

The all-pass filter transfer function is described by .

Derive the overall transfer function H(z) in terms of the filter parameters g and C. Write the transfer function in standard form as the ratio of two polynomials in z.

H ( z ) = 1 + C z 1 1 + C z 1 g C z N g ( 1 + C ) z ( N + 1 ) g z ( N + 2 ) MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8YjY=vipgYlh9vqqj=hEeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9q8qqaq=dir=f0=yqaiVgFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaamisaiaacIcacaWG6bGaaiykaiabg2da9maalaaabaGaaGymaiabgUcaRiaadoeacaWG6bWaaWbaaSqabeaacqGHsislcaaIXaaaaaGcbaGaaGymaiabgUcaRiaadoeacaWG6bWaaWbaaSqabeaacqGHsislcaaIXaaaaOGaeyOeI0Iaam4zaiaadoeacaWG6bWaaWbaaSqabeaacqGHsislcaWGobaaaOGaeyOeI0Iaam4zaiaacIcacaaIXaGaey4kaSIaam4qaiaacMcacaWG6bWaaWbaaSqabeaacqGHsislcaGGOaGaamOtaiabgUcaRiaaigdacaGGPaaaaOGaeyOeI0Iaam4zaiaadQhadaahaaWcbeqaaiabgkHiTiaacIcacaWGobGaey4kaSIaaGOmaiaacMcaaaaaaaaa@5CD2@

Project activity: karplus-strong vmi

As in the prerequisite module , convert the pitch-accurate Karplus-Strong algorithm into a virtual musical instrument ( VMI ) that can be played by "MIDI Jam Session." If necessary, visit MIDI JamSession , download the application VI .zip file, and view the screencast video in that module to learn more about the application and how to create yourown virtual musical instrument. Your VMI will accept parameters that specify frequency, amplitude, and duration of a single note, and will produce a corresponding array ofaudio samples using the Karplus-Strong algorithm described in the previous section.

For best results, select a MIDI music file that contains a solo instrument or perhaps a duet. For example, try "Sonata in A Minor for Cello and Bass Continuo" by Antonio Vivaldi.A MIDI version of the sonata is available at the Classical Guitar MIDI Archives , specifically Vivaldi_Sonata_Cello_Bass.mid .

References

  • Moore, F.R., "Elements of Computer Music," Prentice-Hall, 1990, ISBN 0-13-252552-6.
  • Karplus, K., and A. Strong, "Digital Synthesis of Plucked String and Drum Timbres," Computer Music Journal 7(2): 43-55, 1983.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Musical signal processing with labview -- subtractive synthesis. OpenStax CNX. Nov 07, 2007 Download for free at http://cnx.org/content/col10484/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Musical signal processing with labview -- subtractive synthesis' conversation and receive update notifications?

Ask