Abstract:
In a sound (music) synthesis system, a transition between levels of a sound parameter (e.g. volume) is synthesized by fitting a cubic (third degree) spline function between two discontinuous parameter levels. This advantageously eliminates any sound artifacts (pops or clicks) which would otherwise be present due to abrupt changes in the parameter. The cubic spline is fitted (interpolated) to match both the parameter value and its derivative with respect to time at each of the adjacent parameter levels on either side of the transition. The transition thus is advantageously kept brief and in addition it is possible to deal with the situation when the parameter dynamically changes during the transition period, again without causing undesirable sound artifacts.

Description:
MICROFICHE APPENDIX 
     This disclosure includes a Microfiche Appendix having 1 fiche and 32 total frames. This appendix includes a computer program and is subject to copyright protection. The copyright owner has no objection to facsimile reproduction of the patent document and material in Patent Office files, but otherwise reserves all copyright rights whatsoever. 
     BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     This invention relates to sound synthesis and more specifically to a method and apparatus for preventing sound artifacts (pops and clicks and &#34;zipper&#34; noise) when a sound parameter such as volume level is changed. 
     2. Description of the Prior Art 
     In sound synthesis it is well known that when a sound parameter, such as volume changes, undesirable sound artifacts such as clicks or pops occur. These are wideband sound artifacts caused by an abrupt transition in the sound parameter. These artifacts are also called control noise. FIG. 1A shows graphically a sound waveform 10 inside a volume envelope 12 experiencing an abrupt transition, having corners 14, 16. The horizontal axis is time and the vertical axis is sound volume. The artifacts occur at the time of the transition (at corners 14, 16). 
     Prior art methods to eliminate these artifacts include linear and exponential ramping as shown respectively in FIGS. 1A and 1B. In FIG. 1B a linear ramp 18 is provided between the higher sound level at time t 0  20 and the lower sound level at time t 1  26. This is instead of an abrupt vertical drop as in FIG. 1A which causes the undesirable clicks or pops. A better solution is shown in FIG. 1C where at the lower end of the ramp 22, an exponential decay 24 is provided (an exponential ramp). However, the examples of FIGS. 1B and 1C, even though they cause less of a problem than the vertical change of FIG. 1A, still have the problem that at the corners 20, 26 in FIG. 1B and the single corner 28 in FIG. 1C, the derivative of the ramp function at the corner is discontinuous causing a click or pop. Thus these prior art solutions still have sharp, non-differentiable transitions at the corners and thus are not complete solutions. 
     Another solution is to provide an extended muting period i.e., stretch out the length of the ramp over a much greater time, thus further reducing the sharpness of the corners. However, this still does not completely eliminate the corners and requires a longer time, thus preventing a rapid change in the sound parameter. The muting approach may take as long as 1/10th of a second using an exponential or linear ramp and still not provide complete elimination of the clicking or popping artifacts. Also, the prior art approaches are not capable of dealing with a dynamically changing parameter where the ramp endpoint changes in the middle of ramp, as shown in FIG. 1D, causing a discontinuity at corner 30 in the volume envelope 31, due to a later upward change in target volume level during an earlier downward volume ramp. 
     SUMMARY 
     In accordance with the present invention instead of using a linear or exponential function linking the two sound parameter levels, a cubic spline function is fitted (interpolated) between the two levels of the sound parameter. The cubic spline is matched at both its end points to both the parameter value and its derivative (with respect to time) of the adjacent two parameter levels. For transitions between constant parameter values, the derivatives are set to zero at both ends of the spline function transition and the end points are also made to match up. This consumes all four degrees of freedom in the cubic polynomial. 
     For cases where the sound parameter is being dynamically adjusted, there may be a continuous set of input events specifying new volume values. To avoid the resulting undesirable control noise, for this case the sound parameter and its derivative are also changed smoothly and dynamically. Typically there is a fixed transition interval in which the parameter value is allowed to transition. The interval is mapped over a particular time interval. A cubic spline is fitted dynamically at the beginning of the interval at the moment the transition begins. The end points are matched up and the target derivative of the cubic spline function is set to zero and the derivative is matched at the starting point. 
     Thus the only case when an initial (beginning of the transition) derivative might not be identically zero is if the parameter value is already ramping. This happens if a new target value of the parameter is specified before the old target value has been reached, during the continued series of adjustments of the parameter level. In this case the dynamic adjustment is used to recompute the spline polynomial coefficients to match the end points and derivatives. Thus one insures smoothness and one continuous derivative over the entire transition period. 
     Thus in accordance with the invention there is provided a general mechanism for sound parameter updates. The sound parameter is typically volume but can be other parameters such as frequency, for instance a center frequency for a parametric equalizer. A relatively computationally intensive approach is used to calculate the cubic splines, but this is well within the capabilities of currently available digital signal processors. 
     Moreover, as described above, the present invention advantageously deals with the case of the dynamically changing target value, i.e. in which the target value changes before the transition is complete. The prior art linear and exponential ramp approaches have been found to be ineffective in this case, giving rise to zipper noise due to discontinuities in the envelope&#39;s derivative. However, the present approach deals successfully with this dynamically changing target value case. 
     It is to be noted that the sound parameters described herein typically change for instance (1) under user control (the user adjusting the volume envelope) or (2) in the case of music, in a &#34;note stealing&#34; situation. This happens where there is an insufficient number of oscillators in a sound synthesis system to support all of the needed notes. Then the quietest note is turned off and its resources switched to a new note. In this case, in the prior art the abrupt resulting transition results in a click or pop, and which is eliminated in accordance with the present invention. 
     Also, in accordance with the present invention the spline ramping is used only when an actual transition is detected; otherwise (which is most of the time) the spline fitting function is turned off and no ramping is used. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1A shows an abrupt transition in a sound parameter envelope. 
     FIGS. 1B and 1C show in the prior art respectively a linear ramp to overcome the technical problem shown in FIG. 1A and an exponential ramp to overcome that problem. 
     FIG. 1D shows a dynamic transition in a sound parameter envelope. 
     FIG. 2 shows a cubic spline curve interpolated between two sound parameter levels to eliminate sound artifacts. 
     FIG. 3 shows fitting of two linking cubic spline curves in the case of a dynamically changing sound volume parameter. 
     FIG. 4 shows diagrammatically a process and apparatus for carrying out the present invention. 
    
    
     DETAILED DESCRIPTION 
     FIG. 2 shows graphically in accordance with the present invention the fitting (interpolation) of a cubic spline to link two discontinuous levels of a parameter of a sound. In this example (as above), the parameter is volume. It is to be understood that other parameters such as a center frequency of a parametric equalizer or resampling rate may be used. This graph shows (similar to FIGS. 1A, 1B and 1C) a typical sound as a sinusoidal waveform 32 with the desired volume envelope (level) 36. A mathematical function describing level 36 is f(t); thus the level 36 is a function of the time variable t shown along the horizontal axis. As shown, the volume level 36 is constant up to a time t=t 0 . Then a transition is made to a lower volume level. (A transition to a higher volume level is handled similarly.) The transition period is the time t=t 0  to t=t 0  +Δ. 
     Thus in algebraic terms the volume level is f(t 0 ) at t=t 0  and is f(t 0  +Δ) at t=t 0  +Δ. Similarly the slope of this function, (df/dt) is expressed as f&#39;(t 0 ) at t=t 0  and f&#39;(t 0  +Δ) at t=t 0  +Δ. Thus the cubic spline is the reverse S-shaped curve 38 extending from t=t 0  to t=t 0  +Δ. As explained above, curve 38 is matched at its end points (at t=t 0  and t=t 0  +Δ) to both the value and the derivative with respect to time of the adjacent segments of volume level 36, which are the horizontal portions of the volume envelope. 
     Thus, as shown in FIG. 2, for transitions between constant values of volume, the derivatives are set to zero at both ends i.e., t=t 0  and t=t 0  +Δ of the spline curve, and its end points are also made to match up. This consumes all four degrees of freedom as explained below. FIG. 2 thus shows the relatively simple case for transitions between constant volume values. 
     The more complicated case explained above, and which is even more problematic in the prior art linear or exponential ramping approach, is where the volume level is being adjusted dynamically, up or down. In this case there is e.g. a stream of input events specifying new volume values. To avoid so-called &#34;zipper noise&#34;, in accordance with the invention one changes the effective volume parameter values and their derivatives smoothly. Typically there is a fixed transition interval in which the parameter value is allowed to transition. The interval is mapped in accordance with the present invention as shown in FIG. 3 over a normalized time interval, here for instance, t=-1 to 1, corresponding to the desired transition interval. (Thus t here is not the actual time value, but is normalized over a particular arbitrary length transition interval which is mapped to [-1, 1].) It has been found that it is more advantageous due to considerations of numerical accuracy with fixed point arithmetic to use a normalized time interval of -1 to 1, rather than 0 to 1, but otherwise these time intervals are equivalent. 
     Thus as shown in FIG. 3 a first cubic spline f(t) is fitted at the beginning of the interval beginning at t 0  when the first transition is specified. In this case, the first transition is from the lefthand portion of the volume envelope at 50 down to the lower transition level 54, as shown by f(t). Here again the transition period has a duration Δ. As described above, the cubic spline end points which are at volume level 50 at t=t 0  and the volume level 54 at time t 0  +Δ are matched up, and the target derivative value f&#39;(t 0  +Δ) at time t 0  +Δ, is set to 0 and the derivative f&#39;(t 0 ) is matched to that at the cubic spline starting point at time t 0 . 
     Thus, the only case when an initial derivative might not be identically equal to zero is if the parameter value is already ramping. This happens, as described above, if a new target value is specified before the old target value has been reached. Then as shown in FIG. 3 at time t 1  a new target volume level (indicated by the volume level 60) is specified before the volume parameter arrives at level 54, at time t 1 . The new target volume level in this case is a volume level 60 having as shown a zero derivative. Then by resetting a transition interval timer at time t 1  over the additional time interval Δ extending through time t 1  plus Δ and recomputing the polynomial coefficients using a second cubic spline polynomial g(t), one matches the end point values at times t 1  and t 1  +Δ and matches the derivatives at the endpoints to ensure continuity and smoothness in one continuous change in the derivative. 
     It is to be understood that the one time dynamic change at time t 1  in FIG. 3 is not limiting; there may be a series of input events changing the parameter values. At each such event a transition interval timer as described below is reset and a new cubic spline polynomial is computed. In one embodiment of the invention a preferred transition period Δ is 10 milliseconds, but this is not limiting. 
     Exemplary equations for solving for the polynomial values of the cubic spline are as follows: 
     1. If no ramping is occurring, then the derivative is zero. This may also be folded into the case where there is ramping, by setting the coefficients for the polynomial appropriately. That is, the coefficients of the portions of the polynomial involving t are set equal to zero, and the last (constant) coefficient is set equal to a constant. 
     2. If ramping is currently occurring, the cubic spline polynomial is of the form f(t)=at 3  +bt 2  +ct+d. t is the current time and is normalized as a value between -1 and 1 for convenience of calculation. Then f&#39;(t)=3at 2  +2bt+c. Hence all values are known, both for the derivatives and the actual parameter value at each spline endpoint. Hence having four known values and four unknowns (a, b, c and d) it is easy to solve the equation for a, b, c, and d: 
     Let A=f(t 1 )=at 1   3  +bt 1   2  +ct 1  +d; 
     let B=f&#39;(t 1 )=3at l   2  +2bt 1  +c 
     Then the boundary conditions are for g(t)=a&#39;t 3  +b&#39;t 2  +c&#39;t+d&#39;: 
     let g(-1)=A, so -a&#39;+b&#39;-c&#39;+d&#39;=A, 
     let g&#39;(-1)=B, so 3a&#39;-2b&#39;+c&#39;=B, 
     let g(1)=T, so a&#39;+b&#39;+c&#39;+d&#39;=T, where T is the target value, 
     let g&#39;(1)=0, so 3a&#39;+2b&#39;+c=0. 
     Then solving for four unknowns using four equations: 
     
         b&#39;=-B/4 
    
     
         d&#39;=(A+T)/2+B/4 
    
     
         a&#39;=B/4+(A-T)/4 
    
     and 
     
         c&#39;=3(T-A)/4-B/4 
    
     At the end of the transition interval, the target value of the parameter is understood to be constant and value of the parameter and also the spline coefficients are set to a&#34;=b&#34;=c&#34;=0, and d&#34;=T, where T is the target value of the parameter. This aids in the computation of the next spline coefficient since separate computer code is not needed for the next calculation but the same code can be used again. 
     Hence the execution of the transition ramp synthesis in accordance with the present invention is that such that ramping occurs only during a ramping state. When the ramping state is completed, one enters a non-ramping state where the cubic spline polynomial coefficients are set to zero for the first three coefficients and the last coefficient is set to a constant, hence in effect &#34;shutting down&#34; ramping. 
     Advantageously the present approach allows a relatively short ramping interval without introduction of audio artifacts. This interval is much shorter than in prior art ramping techniques. Also in accordance with the present invention one may advantageously dynamically adjust the output waveform during the ramping interval without introducing any artifacts; this is difficult with prior art approaches. Thus it is possible to have fast and quiet volume changes both up or down. 
     During each ramping interval, a counter counts down to zero from a value which is set to determine the length of the transition (ramping) during the ramping interval. For instance 64 time samples are taken and referred to collectively as a &#34;tick&#34;. In one embodiment, a ramp has a duration of 8 or 16 ticks. Also in accordance with the invention stereo sound is supported with left and right sound channels. In this case a separate cubic spline is calculated for each channel. 
     FIG. 4 shows diagrammatically a method and apparatus (e.g. computer program) for carrying out the present spine fitting. A source 70 of target values (e.g. user control or other source) provides the target parameter and derivative values to a coefficient calculator 74, which performs as described above endpoint matching of the cubic spline for the ramp. The resulting spline coefficients a, b, c, and d are stored in coefficient storage 78. Counter/timer 72 counts from (normalized) time -1 to 1, to operate polynomial spline calculator 80 during this time interval, so as to provide the output parameter signal value. Timer 72 is reset by the source 70, and also times operation of coefficient calculator 74 so calculator 74 only operates during the ramping state. 
     This process is carried out (in one embodiment) by a digital signal processing chip having parallel functional units. See copending and commonly owned U.S. patent application Ser. No. 08/541,565 filed Oct. 10, 1995, inventors James T. Battle, Andy C. Hung, and Stephen C. Purcell, entitled &#34;Multi-Media Engine Including Processor Using Variable Length Instructions&#34; incorporated herein by reference in its entirety. The processor as described in that disclosure allows calculation of for instance four or more individual calculations simultaneously. 
     Further as described above, one embodiment of the present invention is in the form of a computer program (software) for sound (music) synthesis. An example of such a computer program is shown in the Microfiche Appendix which is a part of this disclosure and which is in assembly language and conventionally commentated for understanding. This program includes features not described herein (as evident from the comments). 
     With reference to the code in the Microfiche Appendix, which is paginated at the bottom of each page, the first module entitled waveout --  structs.h beginning at page 1 conventionally defines the data structures. 
     At page 3 (in the middle) the sample size is described: at 44.1 KHz there are 64 samples per tick and 8 ticks, defining a transition length (ramp length) of about 11.6 milliseconds. Of course these parameters may be varied. 
     The core of this program begins at page 5 in the module entitled waveout --  tick.x which is called once per tick. This code calculates the parameter, for instance the volume, as described above. The ramping function begins at page 11, at which is shown how the cubic spline polynomials are calculated. The code at the center of page 11 shows how when the ramping is completed the program reverts to a non-ramping state (see bottom of page 11) at which time the coefficients are set to be constants, thus in effect disabling ramping. 
     The variable temp1 is the value which is incremented for the ramp value between the values of -1 and 1 (a normalized ramp duration). 
     The &#34;mad&#34; operation (multiply and add) shown in the upper portion of page 11 is used multiple times to calculate the cubic spline polynomials, to ultimately calculate ar 2  +br 2  +cr+d using the Horner&#39;s rule calculation. 
     Note the reference to the left and right stereo channels at the bottom of page 12 allowing each channel to have its own ramp using the cubic spline approach. 
     Beginning on page 19, the module entitled waveout --  msgs.x handles message transactions (data/address inputs) from the audio process manager here designated XAPM which is a portion of a related computer program for sound synthesis; this relates to the shell/operating system as described in a commonly owned patent application invented by Avery L. Wang and entitled &#34;A System and Method for Stack Based Processing of Multiple Realtime Audio Tasks&#34; filed Nov. 9, 1995, Ser. No. 08/556,420, and a commonly owned patent application invented by Denis Gulsen and entitled &#34;A System and Method for Fast Context Switch Between Tasks,&#34; filed Nov. 9, 1995, Ser. No. 08/556,416, both incorporated herein by reference in their entirety. 
     Beginning at page 20 of the Microfiche Appendix, there is a code for finite state machine description for the states of ramping up, playing, ramping down, pausing, and closing. Each state pertains to the state of the actual sound, for instance sound provided from a sound file or a CD player. Each state involves potential use of the spline fitting in accordance with the present invention and hence calls, if needed, the spline fitting code. Note that typically there is a transition requiring the spline fitting if one starts playing music, stops playing music, pauses while playing music, or closes the music. This code is further referred to by the module entitled wo --  setup on page 22 and following. 
     Moreover the code beginning at page 25 shows calculation of the ramping spline polynomials over the interval -1 to 1 where there is a dynamic change in the sound parameter, as described above. This code shows the calculation described above of the various coefficients in this case, continuing over to page 26. 
     The code at pages 27 through 30 involves the above-described play, pause, and close states to ramp the sound up or down as appropriate to avoid sound artifacts during the determinative transition period. Note that the close function is typically used in the note stealing situation described above. 
     This disclosure is illustrative and not limiting; further modifications will be apparent to one skilled in the art in the light of this disclosure and are intended to fall within the scope of the appended claims.