Sampling rate conversion device and method and audio playing system
By designing a sampling rate conversion device including a signal sampling unit, a filter coefficient generation unit and a polyphase filter convolution unit, the complex problem of sampling rate conversion operation in the prior art is solved, and a simplified sampling rate conversion process and improved conversion efficiency are realized.
Patent Information
- Application Number
- CN202311220707.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-20
- Publication Date
- 2025-03-21
AI Technical Summary
In the prior art, the operation of audio digital signal sampling rate conversion is complicated and difficult to simplify.
A sampling rate conversion device is designed, including a signal sampling unit, a filter coefficient generation unit and a polyphase filter convolution unit. By sampling the input signal under the control of the decimation factor, a target input sample point is generated, and the filter coefficient is determined based on the basic coefficient table of the polyphase filter to perform convolution operation, and the output sample point is obtained.
No need to use interpolation filters to achieve upsampling or downsampling, simplifying conversion steps and improving conversion efficiency.
Smart Images

Figure CN119673225A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic circuits, and in particular to a sampling rate conversion device, method and audio playback system. Background Art
[0002] Audio sampling rate conversion is the process of converting an audio signal from one sampling rate to another.
[0003] The sampling rate conversion provided in the prior art usually adopts asynchronous sampling rate conversion of audio digital signals, that is, an audio digital input signal is upsampled using an interpolation filter (usually 8 times or 16 times upsampling), and then filtered through an N-tap multi-phase filter to suppress signal aliasing. If it is downsampled (the input sampling rate is greater than the output sampling rate), it is necessary to perform downsampling filtering again to complete the sampling rate conversion task.
[0004] The operation of audio digital signal sampling rate conversion provided by the prior art is relatively complicated. Summary of the invention
[0005] The present invention provides a sampling rate conversion device and method, which are used to solve the problem of relatively complicated operation of sampling rate conversion of audio digital signals existing in the prior art.
[0006] In a first aspect, the present application provides a sampling rate conversion device, including a signal sampling unit, a filter coefficient generation unit, and a polyphase filter convolution unit;
[0007] The signal sampling unit is used to sample the input signal under the control of a decimation factor to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate;
[0008] The filter coefficient generating unit is used to determine the target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on the polyphase filter basic coefficient table, and determine the historical filter coefficient corresponding to the historical sample point according to the sample point address information of the target input sample point, wherein the polyphase filter basic coefficient table is used to characterize the corresponding relationship between the interpolation sample point and the polynomial coefficient;
[0009] The polyphase filter convolution unit is used to perform a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is the target input sample point sampled by the signal sampling unit before the current moment.
[0010] In a possible implementation, the device further includes a first storage unit and a second storage unit, the data in the polyphase filter basic coefficient table is in an even symmetric format, and the polyphase filter basic coefficient table includes a first polyphase filter basic coefficient table representing upsampling and a second polyphase filter basic coefficient table representing downsampling;
[0011] The first storage unit is used to store a set of symmetric data in the first polyphase filter basic coefficient table;
[0012] The second storage unit is used to store a group of symmetric data in the second polyphase filter basic coefficient table.
[0013] In a possible implementation, the device further includes a control unit;
[0014] The control unit is configured to determine a sampling mode according to the input sampling rate and the output sampling rate; if the sampling mode is upsampling, control the filter coefficient generation unit to determine the filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on the first polyphase filter basic coefficient table stored in the first storage unit; if it is determined that the sampling mode is downsampling, control the filter coefficient generation unit to determine the filter coefficient corresponding to the target input sample point according to the target input sample point and based on the second polyphase filter basic coefficient table stored in the second storage unit.
[0015] In a possible implementation manner, before controlling the filter coefficient generating unit to determine the filter coefficient corresponding to the target input sample point according to the target input sample point and based on the second polyphase filter basic coefficient table stored in the second storage unit, the control unit is further configured to:
[0016] The filter coefficient generation unit is controlled to read the second polyphase filter basic coefficient table from an external storage area.
[0017] In a possible implementation, the signal sampling unit includes a first first-in first-out queue and an address generation subunit;
[0018] The first first-in-first-out queue is used to store input signals sent by the audio input device;
[0019] The address generation subunit is used to determine the sample point address information according to the extraction factor, and read the target input sample point from the input signal stored in the first FIFO queue according to the determined sample point address information.
[0020] In a possible implementation, it also includes a sample point historical data storage unit;
[0021] The sample point historical data storage unit is used to store the target input sample points sampled by the signal sampling unit, and use the target input sample points as historical sample points.
[0022] In a possible implementation manner, the filter coefficient generating unit is specifically used to:
[0023] Determine a target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table;
[0024] Using the polynomial coefficients corresponding to the target interpolation sample points in the polyphase filter basic coefficient table as initial filter coefficients;
[0025] Based on the sample point address information of the target input sample point and the position information of the target interpolation sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0026] In a possible implementation manner, the filter coefficient generating unit is specifically used to:
[0027] Determine interpolation sample point position information corresponding to the target input sample point according to the sample point address information of the target input sample point and a preset target interpolation magnification;
[0028] According to the interpolation sample point position information corresponding to the target input sample point, the target interpolation sample point is selected from the polyphase filter basic coefficient table by adopting the principle of the shortest distance.
[0029] In a possible implementation manner, the filter coefficient generating unit is specifically used to:
[0030] Based on the decimal part of the interpolation sample point position information corresponding to the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0031] In a possible implementation manner, the filter coefficient generating unit is specifically used to:
[0032] Determine the interpolation sample point position information corresponding to the historical sample point according to the interpolation sample point position information corresponding to the target input sample point, the position of the historical sample point in the sample point historical data storage unit, and the target interpolation magnification;
[0033] The historical filter coefficients corresponding to the historical sample points are determined according to the interpolation sample point position information corresponding to the historical sample points and the polyphase filter basic coefficient table.
[0034] In a possible implementation manner, the polyphase filter convolution unit is specifically used to:
[0035] Performing a convolution operation on the target input sample point and the target filter coefficient, and performing a convolution operation on the historical sample point and the filter coefficient corresponding to the historical sample point;
[0036] The sum of the convolution operation results is used as the output sample point corresponding to the target input sample point.
[0037] In a possible implementation, the device further includes a second first-in first-out queue;
[0038] The second first-in-first-out queue is used to store the generated output samples in sequence.
[0039] In a possible implementation, the device further includes a fade-in and fade-out unit;
[0040] The fade-in and fade-out unit is used to adjust the amplitude value of the output signal composed of the output sample points by adopting a preset amplitude variation rule.
[0041] In a second aspect, the present application further provides an audio playback system, comprising an audio input device, an audio output device, and a sampling rate conversion device as described in any one of the first aspects, wherein:
[0042] The audio input device is used to send an input signal to the sampling rate conversion device;
[0043] The audio output device is used to receive the output signal sent by the sampling rate conversion device.
[0044] In a third aspect, the present application further provides a sampling rate conversion method, which is applied to the sampling rate conversion device as described in any one of the first aspects, and the method includes:
[0045] Under the control of a decimation factor, sampling the input signal to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate;
[0046] Determine, according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table, a target filter coefficient corresponding to the target input sample point, and determine, according to the sample point address information of the target input sample point, a historical filter coefficient corresponding to the historical sample point, wherein the polyphase filter basic coefficient table is used to characterize the correspondence between the interpolation sample point and the polynomial coefficient;
[0047] A convolution operation is performed on the target input sample point, the target filter coefficient, the historical sample point, and the filter coefficient corresponding to the historical sample point to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is a target input sample point sampled before a current moment.
[0048] In a possible implementation manner, before determining the filter coefficient corresponding to the target input sample point based on the target input sample point and a polyphase filter basic coefficient table, the method further includes:
[0049] Determining a sampling mode according to the input sampling rate and the output sampling rate;
[0050] If the sampling mode is upsampling, the filter coefficient corresponding to the target input sample point is determined according to the sample point address information of the target input sample point and based on a first polyphase filter basic coefficient table used to characterize upsampling; if it is determined that the sampling mode is downsampling, the filter coefficient corresponding to the target input sample point is determined according to the sample point address information of the target input sample point and based on a second polyphase filter basic coefficient table used to characterize downsampling.
[0051] In a possible implementation manner, before determining the filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on a second polyphase filter basic coefficient table used to characterize downsampling, the method further includes:
[0052] The filter coefficient generating unit is controlled to read the second polyphase filter basic coefficient table from the external storage area.
[0053] In a possible implementation, sampling the input signal under the control of the decimation factor to obtain a target input sample point includes:
[0054] Determining the sampling point address information according to the extraction factor;
[0055] The target input sample point is read from the stored input signal according to the determined sample point address information.
[0056] In a possible implementation, determining the target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table includes:
[0057] Determine a target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table;
[0058] Using the polynomial coefficients corresponding to the target interpolation sample points in the polyphase filter basic coefficient table as initial filter coefficients;
[0059] Based on the sample point address information of the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0060] In a possible implementation, determining the target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table includes:
[0061] Determine a target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table;
[0062] Using the polynomial coefficients corresponding to the target interpolation sample points in the polyphase filter basic coefficient table as initial filter coefficients;
[0063] Based on the sample point address information of the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0064] In a possible implementation, performing polynomial calculation on the initial filter coefficient based on the sample address information of the target input sample to obtain the target filter coefficient includes:
[0065] Based on the decimal part of the interpolation sample point position information corresponding to the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0066] In a possible implementation, determining the historical filter coefficients corresponding to the historical sample points according to the sample point address information of the target input sample points includes:
[0067] Determine the interpolation sample point position information corresponding to the historical sample point according to the interpolation sample point position information corresponding to the target input sample point, the position of the historical sample point in the sample point historical data storage unit, and the target interpolation magnification;
[0068] The filter coefficients corresponding to the historical sample points are determined according to the interpolation sample point position information corresponding to the historical sample points and the polyphase filter basic coefficient table.
[0069] In a possible implementation manner, performing a convolution operation on the target input sample, the target filter coefficient, the historical sample, and the historical filter coefficient to obtain an output sample corresponding to the target input sample includes:
[0070] Performing a convolution operation on the target input sample point and the target filter coefficient, and performing a convolution operation on the historical sample point and the historical filter coefficient;
[0071] The sum of the convolution operation results is used as the output sample point corresponding to the target input sample point.
[0072] In a possible implementation, the method further includes:
[0073] The amplitude value of the output signal composed of the output sample points is adjusted using a preset amplitude variation rule.
[0074] The beneficial effects of the present invention are as follows:
[0075] The present application provides a sampling rate conversion device and method, wherein the sampling rate conversion device includes a signal sampling unit, a filter coefficient generation unit and a polyphase filter convolution unit; the signal sampling unit is used to sample an input signal under the control of a decimation factor to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate; the filter coefficient generation unit is used to determine a target filter coefficient corresponding to a target input sample point and a historical filter coefficient corresponding to a historical sample point according to sample point address information of the target input sample point and based on a polyphase filter basic coefficient table, wherein the polyphase filter basic coefficient table is used to characterize the correspondence between interpolation sample points and polynomial coefficients; the polyphase filter convolution unit is used to perform a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is a target input sample point sampled before a current moment. Since the filter coefficient generation unit in the present application can determine the target filter coefficient corresponding to the target input sample point and the historical filter coefficient corresponding to the historical sample point according to the sample point address information of the target input sample point and the polyphase filter basic coefficient table, the polyphase filter convolution unit performs a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical sample filter coefficient to obtain the output sample point, there is no need to use an interpolation filter to achieve upsampling, and there is no need to use an interpolation filter for downsampling, thereby simplifying the conversion steps and improving the conversion efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0077] Figure 1 A schematic diagram of an application scenario of a sampling rate conversion device provided by an embodiment of the present invention;
[0078] Figure 2 A schematic diagram of the structure of a sampling rate conversion device provided by an embodiment of the present invention;
[0079] Figure 3 A schematic diagram of the structure of another sampling rate conversion device provided by an embodiment of the present invention;
[0080] Figure 4 A schematic diagram of the structure of another sampling rate conversion device provided by an embodiment of the present invention;
[0081] Figure 5 A schematic diagram of the structure of another sampling rate conversion device provided by an embodiment of the present invention;
[0082] Figure 6 A schematic diagram of a filter coefficient corresponding to a target input sample point obtained in a polyphase filter basic coefficient table provided by an embodiment of the present invention;
[0083] Figure 7 A schematic diagram of another filter coefficient corresponding to a target input sample point obtained in a polyphase filter basic coefficient table provided by an embodiment of the present invention;
[0084] Figure 8 A schematic diagram of a corresponding relationship between input sample points and filter coefficients provided by an embodiment of the present invention;
[0085] Fig. 9 A schematic diagram of an audio system provided by an embodiment of the present invention;
[0086] Fig.10 A schematic flow chart of a sampling rate conversion method provided by an embodiment of the present invention;
[0087] Fig.11 A complete flow chart of a sampling rate conversion method provided by an embodiment of the present invention;
[0088] Fig.12 A test schematic diagram provided for an embodiment of the present invention;
[0089] Fig.13 Another test schematic diagram provided for an embodiment of the present invention;
[0090] Fig.14 Another test schematic diagram provided for an embodiment of the present invention;
[0091] Fig.15 Another test schematic diagram provided for an embodiment of the present invention;
[0092] Fig.16 Another test schematic diagram provided for an embodiment of the present invention;
[0093] Fig.17 Another test schematic diagram provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0094] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0095] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0096] The embodiments of the present invention provide a sampling rate conversion device, method and audio playback system, which are used to solve the problem that the operation of sampling rate conversion of audio digital signals provided in the related art is relatively complicated.
[0097] The technical solution in the embodiment of the present invention will be described below in conjunction with the accompanying drawings:
[0098] Figure 1 A schematic diagram of an application scenario of a sampling rate conversion device provided in an embodiment of the present invention is shown. Figure 1 As shown, the audio playback system includes an audio acquisition device 11, an integrated circuit 21 and an audio playback device 14, wherein the integrated circuit 21 includes an analog-to-digital converter 211, a sampling rate conversion device 212, a sound effect processor 213 and a digital-to-analog converter 214 electrically connected in sequence.
[0099] In a specific implementation, the audio acquisition device 11 acquires sound signals and sends the acquired sound signals to the integrated circuit 21 for processing. In the process of the integrated circuit 21 processing the acquired sound signals: first, the analog-to-digital converter 211 converts the sound signal into a digital signal with an input sampling rate, and transmits the digital signal with the input sampling rate to the sampling rate conversion device 212; then, the sampling rate conversion device 212 performs sampling rate conversion on the digital signal with the input sampling rate to obtain a digital signal with an output sampling rate, and transmits the digital signal with the output sampling rate to the sound effect processor 213 for sound effect processing; finally, the digital signal processed with sound effects is sent to the digital-to-analog converter 214, so that the digital-to-analog converter 214 converts the digital signal processed with sound effects into a sound signal, and sends the sound signal to the audio playback device 14 for playback.
[0100] It should be noted that the audio acquisition device 11 in the embodiment of the present invention can be a microphone, a voice recorder, or other devices for collecting sound, and the embodiment of the present invention does not impose any restrictions on this; in addition, the audio playback device 14 in the embodiment of the present invention can be a speaker, a sound system, or other devices for playing sound, and the embodiment of the present invention does not impose any restrictions on this.
[0101] In addition, in the embodiment of the present invention, other essential components of the audio playback system are well understood by those skilled in the art and are not described in detail herein and should not be construed as limiting the present invention.
[0102] It should be noted that the sampling rate conversion device provided in the embodiment of the present invention can be applied in Figure 1 The audio playback system shown can also be applied to other systems that require sampling rate conversion, and the embodiment of the present invention does not impose any limitation on this.
[0103] The following is a description of a sampling rate conversion device provided by the present invention through a specific embodiment. Figure 2 As shown, the sampling rate conversion device includes a signal sampling unit 31, a filter coefficient generating unit 32 and a polyphase filter convolution unit 33;
[0104] A signal sampling unit 31, used to sample the input signal under the control of a decimation factor to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate;
[0105] a filter coefficient generating unit 32, configured to determine the filter coefficient corresponding to the target input sample point according to the target input sample point and based on a polyphase filter basic coefficient table, and to determine the historical filter coefficient corresponding to the historical sample point according to the sample point address information of the target input sample point, wherein the polyphase filter basic coefficient table is used to characterize the correspondence between the interpolation sample point and the polynomial coefficient;
[0106] The multi-phase filter convolution unit 33 is used to perform a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is the target input sample point sampled by the signal sampling unit before the current moment.
[0107] Since the filter coefficient generating unit in the embodiment of the present application can determine the target filter coefficient corresponding to the target input sample point and the historical filter coefficient corresponding to the historical sample point based on the target input sample point and the polyphase filter basic coefficient table, the polyphase filter convolution unit can perform a convolution operation on the target input sample point and the historical sample point based on the target filter coefficient and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point. Therefore, there is no need to use an interpolation filter to achieve upsampling, nor is there a need to use an interpolation filter for downsampling, thereby simplifying the conversion steps and improving conversion efficiency.
[0108] It should be noted that the basic coefficient table of the multi-phase filter in the embodiment of the present application can be determined based on the address information after the input signal is upsampled N times, where N is a positive integer.
[0109] The decimation factor in the embodiment of the present application is the ratio of the input sampling rate to the output sampling rate. If the ratio is greater than 1, it is downsampling; if the ratio is less than 1, it is upsampling.
[0110] In one embodiment, if Figure 4 As shown, the signal sampling unit 31 may include a first first-in first-out queue 311 and an address generating subunit 312;
[0111] A first FIFO queue 311, for storing input signals sent by an audio input device;
[0112] The address generating subunit 312 is used to determine the sample point address information according to the decimation factor, and read the target input sample point from the input signal stored in the first FIFO queue 311 according to the determined sample point address information.
[0113] In a specific implementation, for a certain playback task, the initial value of the sample point address information pos is 0, the address generation subunit 312 updates the sample point address information pos according to the extraction factor deci_ratio, and reads the input sample point at the corresponding position of the first first-in-first-out queue 311 according to the updated sample point address information, and the read input sample point is the target input sample point.
[0114] In the embodiment of the present invention, the first FIFO queue 311 may be a 32-level 32-bit wide FIFO queue.
[0115] Exemplarily, assuming that the input sampling rate is 24KHz and the output sampling rate is 48KHz, the extraction factor deci_ratio = 24KHz / 48KHz = 0.5, and assuming that at the initial moment, the input sample points stored in the first first-in first-out queue 311 are represented as: in1, in2, in3...in(m), and the output sample points calculated based on the input sample points are set to: out1, out2, out3, out4...out(n).
[0116] For the above example, the specific process of sampling the input sample points is as follows: first, the first target output sample point out1 is calculated: at this time, the sample point address information pos determined by the address generation subunit 312 is the initial value, that is, the sample point address information pos=0, then the 0th input sample point in1 is read from the input sample points stored in the first first-in first-out queue 311, and the read input sample point in1 is cached, the address generation subunit 312 obtains the cached input sample point in1, and uses the input sample point in1 as the target input sample point for determining the output sample point out1. After the output sample point out1 is calculated, the address generation subunit 312 generates the sample point in1 according to the initial sampling. The sampling point address information pos is updated by the factor deci_ratio=0.5, and the updated sampling point address information pos is: pos=pos+deci_ratio=0+0.5=0.5, and it is identified whether the value of the integer part of the updated sampling point address information pos jumps. For example, if the sampling point address information is updated from pos=0 to pos=0.5, since the value of the integer part of the sampling point address information pos is 0, no jump occurs; if the sampling point address information is updated from pos=0.5 to pos=1.5, since the value of the integer part of the sampling point address information pos jumps from 0 to 1, a jump occurs;
[0117] Then, the second output sample out2 is calculated: at this time, the input sample in1 is cached in the cache area of the sampling rate conversion device, the input sample stored in the first first-in first-out queue 311 is represented as: in2, in3...in(m), the sample address information pos is the updated sample address information, that is, the sample address information pos=0.5, and the value of the integer part of the sample address information pos=0.5 has not changed, then the address generation subunit 312 obtains the input sample in1 cached in the cache area, and uses the input sample in1 as the target input sample for determining the output sample out2. After the output sample out2 is calculated, the address generation subunit 312 updates the sample address information pos according to the decimation factor deci_ratio=0.5, then the updated sample address information pos is: pos=pos+deci_ratio=0.5+0.5=1, and identifies whether the value of the integer part of the updated sample address information pos has changed;
[0118] Next, the third output sample out3 is calculated: At this time, the input samples stored in the first FIFO queue 311 are represented as: in2, in3…in(m), the sample address information pos is the updated sample address information, that is, the sample address information pos=1, and the value of the integer part of the sample address information pos=1 jumps from 0 to 1, then the first input sample in2 is read from the input samples stored in the first FIFO queue 311, and the read input sample in2 is cached in the buffer area, and the address generation subunit 31 2. Obtain the input sample point in2 cached in the buffer area, and use the input sample point in2 as the target input sample point for determining the output sample point out3. After the output sample point out3 is calculated, the address generation subunit 312 updates the sample point address information pos according to the decimation factor deci_ratio=0.5. The updated sample point address information pos is: pos=pos+deci_ratio=1.+0.5=1.5, and it is identified whether the value of the integer part of the updated sample point address information pos jumps.
[0119] Next, the fourth output sample out4 is calculated: at this time, the input sample in2 is cached in the cache area of the sampling rate conversion device, the input samples stored in the first first-in-first-out queue 311 are expressed as: in3, in4...in(m), the sample address information pos is the updated sample address information, that is, the sample address information pos=1.5, and the value of the integer part of the sample address information pos=1.5 does not jump, then the address generation subunit 312 obtains the input sample in2 cached in the cache area, and uses the input sample in2 as the target input sample for determining the output sample out4, and the address generation subunit 312 updates the sample address information pos according to the extraction factor deci_ratio_, and so on, until the current playback task is completed.
[0120] It should be noted that the decimation factor deci_ratio in the embodiment of the present invention is a floating point number. Therefore, the sampling rate conversion device can perform fixed-point processing on the decimation factor. Specifically, the decimal part of the decimation factor is fixed-pointed to 48 bits. In this way, the sampling rate conversion device can calculate accurately according to the decimation factor. sample points, improving the accuracy of sampling rate conversion equipment.
[0121] like Figure 3 As shown, the sampling rate conversion device provided in the embodiment of the present application may further include a sample point history data storage unit 34, and the sample point history data storage unit 34 is used to store the target input sample points read by the address generation subunit 312 as historical sample points.
[0122] In the embodiment of the present application, the size of the sample point history data storage unit 34 can be 2*N*32 bits, and the maximum value of N is 64.
[0123] The updating principle of the sample points stored in the sample point historical data storage unit 34 is first-in-first-out, that is, when the current sample point enters the sample point historical data storage unit 34, the earliest sample point will be removed from the sample point historical data storage unit 34.
[0124] The data in the sample point historical data storage unit 34 is arranged so that the earliest sample point is written at the head of the data area and the latest sample point is written at the tail of the data area. Such data arrangement facilitates convolution calculation of the polyphase filter.
[0125] The sampling conversion device provided in the embodiment of the present application may further include a second first-in-first-out queue 35, and the second first-in-first-out queue 35 is used to store the generated output sample points in sequence.
[0126] In a specific implementation, the sampling rate conversion device provided in the embodiment of the present application may further include a control unit 36, an address generation subunit 312 determines the sample point address information pos according to the extraction factor deci_ratio, reads the target input sample point from the input signal stored in the first first-in first-out queue 311 according to the determined sample point address information pos, and transmits the target input sample point to the sample point history data storage unit 34 and the polyphase filter convolution unit 33 via the control unit 36, and after the sample point history data storage unit 34 receives the target input sample point, it stores the target input sample point and uses it as a historical sample point in subsequent convolution filtering; after the address generation subunit 312 determines the sample point address information pos, the control unit 36 sends the sample point address information pos to the sample point history data storage unit 34 and the polyphase filter convolution unit 33. s is sent to the filter coefficient generating unit 32. After receiving the sample point address information pos, the filter coefficient generating unit 32 generates the target filter coefficient corresponding to the target input sample point and the historical filter coefficient corresponding to the historical sample point according to the sample point address information pos and the multi-phase filter basic coefficient table, and the control unit 36 sends the target filter coefficient and the historical filter coefficient to the multi-phase filter convolution unit 33; the multi-phase filter convolution unit 33 obtains the historical sample points stored in the sample point historical data storage unit 34, and performs convolution calculation on the received target input sample points based on the target filter coefficients, and performs convolution calculation on the acquired historical sample points based on the historical filter coefficients to obtain output sample points, and stores the output sample points in the second first-in-first-out queue 35.
[0127] In the embodiment of the present application, the control unit 36 is responsible for scheduling the work between each unit, receiving and sending signals, and processing these signals in a timely manner. The working process of the state machine of the control unit 36 is as follows: read the input sample point from the first first-in first-out queue FIFO_IN, that is, the RDAT state. If the first first-in first-out queue FIFO_IN is empty, wait until the required data is read; before performing multi-phase filtering, the control unit 36 first checks whether the second first-in first-out queue FIFO_OUT is full. If it is full, it is in the WAIT_DATA state. In the WAIT_DATA state, the filtering needs to be suspended, that is, HOLD_FILTER, until the second first-in first-out queue FIFO_OUT is not full, then enter the FILTER_PROC state to start filtering. After the filtering is completed, the data is written to the second first-in first-out queue FIFO_OUT output, and the conversion of an output sample point is completed. If the device shutdown signal is received, enter the END state to exit, otherwise continue the conversion of the next output sample point.
[0128] The basic coefficient table of the multi-phase filter in the embodiment of the present invention can be stored in the memory of the audio playback system, for example, on an SD card or a NAND storage medium. When in use, the MCU is required to import the corresponding basic coefficient table of the multi-phase filter into the storage unit RAM in the sampling rate conversion device according to the input sampling rate and the output sampling rate.
[0129] The MCU imports the corresponding polyphase filter basic coefficient table into the storage unit according to the input sampling rate and the output sampling rate. Specifically, if the input sampling rate is less than the output sampling rate, it represents upsampling, and the polyphase filter basic coefficient table corresponding to the upsampling is imported into the storage unit. If the input sampling rate is greater than the output sampling rate, it represents downsampling, and the MCU imports the polyphase filter basic coefficient table corresponding to the downsampling into the storage unit.
[0130] The basic coefficient table of the multi-phase filter can also be stored in the sampling rate conversion device, for example, directly stored in ROM or RAM. The filter coefficient generation unit 32 can directly obtain the data in the basic coefficient table of the multi-phase filter according to the input sampling rate and the output sampling rate. The embodiment of the present invention does not impose any restrictions on this.
[0131] In a specific implementation, the basic coefficient table of the multi-phase filter corresponding to the up-sampling rate can be solidified in the hardware storage unit ROM, and the basic coefficient table of the multi-phase filter corresponding to the down-sampling rate can be stored on an SD card or a NAND storage medium. Before the sampling rate conversion device is started, the basic coefficient table of the multi-phase filter to be used is determined according to the input sampling rate and the output sampling rate, and the corresponding table data storage address (ROM address or RAM address) is configured for the sampling rate conversion device. When the sampling rate conversion device is working, the data in the basic coefficient table of the multi-phase filter is read from the corresponding address according to the configured table data storage address.
[0132] In one embodiment, if the polyphase filter basic coefficient table corresponds to upsampling, both 8x and 16x interpolation can be supported.
[0133] Optionally, the polyphase filter basic coefficient table is a pre-designed table, which can be designed according to the order of the polyphase filter in the polyphase filter convolution unit 32 in the sampling rate conversion device. For example, it can be designed that the higher the order of the polyphase filter, the more data in the polyphase filter basic coefficient table. In a specific implementation, the data in the polyphase filter basic coefficient table can be designed to be left-right symmetrical. Therefore, when storing the polyphase filter basic coefficient table, only 1 / 2 of the data in the polyphase filter basic coefficient table needs to be stored, wherein one coefficient component in the data of the polyphase filter basic coefficient table can be represented by 128 bits, thereby reducing the storage space used to store the polyphase filter basic coefficient table.
[0134] Exemplarily, the design process of the basic coefficient table of the multi-phase filter can be: perform an X-fold upsampling interpolation operation on the input signal to obtain a series of interpolation sample points, each interpolation sample point has its own corresponding filter coefficient, and the filter coefficients corresponding to each interpolation sample point are integrated together to form a data table, which is the basic coefficient table of the multi-phase filter. Among them, since the basic table part of the polyphase filter is designed to be evenly symmetrical, the basic table part of the polyphase filter has 2N+1 data. The above data is centered on N, and the values on the left and right sides are evenly symmetrical and equal, that is, the data content of the N-1 position table is the same as the data content of the N+1 position table, the data content of the N-2 position table is the same as the data content of the N+2 position table, ..., the data content of the 0 position table is the same as the data content of the 2N position table; the coefficients of the polynomial coefficient table part are arranged in sequence as follows: 0, 1, 2, N-2, N-1, N, N+1, N+2, ...2N, since the coefficients of the polynomial coefficient table part are also left-right symmetrical, therefore, only data from 0 to N+1 need to be stored, and the data content of the polynomial coefficient table part is the polynomial coefficient of a 4th-order polynomial approximate calculation function, occupying 128 bits of storage space.
[0135] For example, a 4th-order polynomial is used as an example. For a 4th-order polynomial, there are 5 sets of polynomial coefficients for each interpolation sample point. In descending order of polynomial order, the 5 sets of coefficients are polynomial coefficient a, polynomial coefficient b, polynomial coefficient c, polynomial coefficient d, and polynomial coefficient e.
[0136] Assume that the polynomial coefficient a has 17 coefficients, namely coefficients 0 to 16. The design will be centered on coefficient 8, and the coefficient values on the left and right sides of coefficient 8 will be designed to be symmetrical and equal (the value of coefficient 7 = the value of coefficient 9, the value of coefficient 6 = the value of coefficient 10...). When storing the table coefficients, only coefficients 0 to 8 need to be stored, and coefficients 9 to 16 do not need to be stored (they are equal to the corresponding coefficients 7 to 0).
[0137] The other polynomial coefficient tables b, c, d, and e are similar to the polynomial coefficient table a. The coefficients in the coefficient tables are designed to be 2N+1, and N is the center point, and the coefficient values on both sides of the center point are symmetrical and equal.
[0138] Table 1 is a basic coefficient table of a polyphase filter provided in an embodiment of the present application.
[0139]
[0140] Table 1
[0141] It should be noted that the polynomial coefficient table in the embodiment of the present application is designed so that the coefficients of the 1st and 3rd order polynomials are odd functions, and the coefficients of the 2nd and 4th order polynomials are even functions. According to the even-odd property, only half of the polynomial coefficients need to be stored in the system MEMORY, saving half of the storage space.
[0142] In an embodiment of the present application, the basic coefficient table of the polyphase filter is designed as an even function with a length of 2M+1. The data in the table is centered on the M+1 point, and the data on the left and right sides of the center point are symmetrical. Therefore, only M+1 coefficients need to be stored, thereby saving half of the table data storage space.
[0143] When the basic coefficient table of the polyphase filter is implemented, the M polynomial coefficients are just the minimum storage unit of the system MEMORY. If the M+1th polynomial coefficient is also written to the system memory MEMORY, it will cause a waste of storage space. Therefore, when implementing, the polynomial coefficients in the 1st to Mth tables can be written to the system MEMORY, and the polynomial coefficients in the M+1th table can be written to the register, thus saving a minimum storage unit.
[0144] When the sampling rate conversion device is working, when reading the basic coefficient table of the polyphase filter, the system memory management unit will map the coefficients in the MEMORY and the register together, that is, the table data address space when reading the polyphase filter coefficients in the sampling rate conversion device is continuous.
[0145] Due to the simplification of the downsampling filter, there are multiple polyphase filter basic coefficient tables, one for upsampling conversion, and the others for downsampling conversions of different specifications. Before the sampling rate conversion device is started, the operating system loads the corresponding polyphase filter basic coefficient table to MEMORY according to the sampling rate conversion requirements. For example, if it is an upsampling conversion, the polyphase filter basic coefficient table corresponding to the upsampling is loaded, and if it is a downsampling conversion, the polyphase filter basic coefficient table corresponding to the downsampling is loaded.
[0146] The sampling rate conversion device uses a 4th-order polynomial calculation to dynamically generate the multi-phase filter coefficients, that is, the tap coefficients of the multi-phase filter. In this polynomial, the 1st-order polynomial coefficient and the 3rd-order polynomial coefficient are odd functions, and the 2nd-order polynomial coefficient and the 4th-order polynomial coefficient are even functions. According to the parity characteristic, only half of the polynomial coefficient table data needs to be stored.
[0147] Each coefficient component in the basic coefficient table of the polyphase filter can be represented by 128 bits. Therefore, when the entire table has 2M+1 coefficients, the table data space size is (2M+1)*4 bytes.
[0148] In a specific implementation, the target input sample point is set to S1. After the filter coefficient generating unit 32 receives the target input sample point S1, it determines the target filter coefficient according to the sample point address information pos of the target input sample point S1 and based on the polyphase filter basic coefficient table. Specifically, the target interpolation sample point is determined according to the sample point address information pos of the target input sample point S1 and the position information of the interpolation sample point in the polyphase filter basic coefficient table, and then the polynomial coefficient corresponding to the target interpolation point in the polyphase filter basic coefficient table is used as the initial filter coefficient.
[0149] In one embodiment, when determining the target interpolation sample point, first determine the interpolation sample point position information corresponding to the target input sample point based on the sample point address information of the target input sample point and a preset target interpolation magnification, and then select the target interpolation sample point from the polyphase filter basic coefficient table based on the interpolation sample point position information corresponding to the target input sample point and the principle of the closest distance.
[0150] For example, the target input sample point is the target input sample point S1, and the sample point address information pos of the target input sample point S1 is 1.35. Then the interpolation sample point position information corresponding to the target input sample point S1 is 0.35 multiplied by the target interpolation factor N. If the target interpolation factor N is 8, then the interpolation sample point position information corresponding to the target input sample point S1 is N×[M-1]+0.35×8=8×[5-1]+0.35×8=34.8, where M is the order of the polyphase filter.
[0151] Determine the position of the target input sample point S1 between the interpolation sample points in the basic coefficient table of the polyphase filter. For example, as shown in Table 1, the interpolation sample points in the basic coefficient table of the polyphase filter include interpolation sample point 1, interpolation sample point 2, interpolation sample point 3, interpolation sample point 4 ... interpolation sample point n, wherein interpolation sample point 1, interpolation sample point 2, interpolation sample point 3, interpolation sample point 4 ... interpolation sample point n can be determined by the address information of the input signal received by the sampling rate conversion device after N-fold upsampling. In the process of generating the filter coefficient corresponding to the target input sample point S1, there are the following two situations:
[0152] Scenario 1:
[0153] like Figure 6 and Figure 7As shown, according to the interpolation sample point position information corresponding to the target input sample point S1, it is determined that the target input sample point S1 is located between the interpolation sample point 35 and the interpolation sample point 36, that is, the position of the target input sample point S1 mapped to the N-fold interpolation queue is located between the interpolation sample point 35 and the interpolation sample point 36. It should be noted that the N-fold interpolation queue is the queue of interpolation sample points in Table 1, interpolation sample point 1, interpolation sample point 2, interpolation sample point 3, interpolation sample point 4... interpolation sample point n. It should also be noted that the interpolation sample point position information corresponding to the interpolation sample point 1 is 0, the interpolation sample point position information corresponding to the interpolation sample point 2 is 1, the interpolation sample point position information corresponding to the interpolation sample point 3 is 2..., then the generation process of the target filter coefficient corresponding to the target input sample point S1 is:
[0154] Step 1, according to the address information pos of the target input sample point S1, calculate the interpolation sample point position information corresponding to the target input sample point S1, and then calculate the first distance L1 between the target input sample point S1 and the interpolation sample point 35, and the second distance L2 between the target input sample point S1 and the interpolation sample point 36 respectively according to the interpolation sample point position information corresponding to the target input sample point S1;
[0155] For example, Figure 4 As shown, assuming that the sample point address information pos of the target input sample point S1 is 1.35, N=8, then the interpolation sample point position information corresponding to the target input sample point S1 is 8×[5-1]+0.35×8=34.8. Since the position information of the interpolation sample point 35 is 34, and the position information of the interpolation sample point 36 is 35, the distance between the target input sample point S1 and the interpolation sample point 35 is 0.8, that is, the first distance L1=0.8; the distance between the target input sample point S1 and the interpolation sample point 36 is 0.2, that is, the second distance L2=0.2.
[0156] Step 2, according to the relationship between the first distance L1 and the second distance L2, determine the target interpolation sample point according to the principle of the shortest distance;
[0157] Specifically, if the first distance L1<the second distance L2, the interpolation sample point 35 is used as the target interpolation sample point; if the second distance L2<the first distance L1, the interpolation sample point 36 is used as the target interpolation sample point; if the first distance L1=the second distance L2, the interpolation sample point 35 is used as the target interpolation sample point, or the interpolation sample point 36 is used as the target interpolation sample point.
[0158] For example, Figure 4 As shown, the first distance L1=0.8, the second distance L2=0.2, the first distance L1>the second distance L2, and the interpolation sample point 36 is used as the target interpolation sample point.
[0159] For example, Figure 5As shown, the first distance L1=0.5, the second distance L2=0.5, and the first distance L1=the second distance L2, then the interpolation sample point 35 is used as the target interpolation sample point, or the interpolation sample point 36 is used as the target interpolation sample point.
[0160] It should be noted that when the distances between the target input sample point S1 and the two interpolation sample points are equal, it can be set which interpolation sample point is selected as the target interpolation sample point.
[0161] Step 3: According to the target interpolation sample point, the polynomial coefficient corresponding to the target interpolation sample point is taken out from the polyphase filter basic coefficient table, and the polynomial coefficient is used as the initial filter coefficient; then, according to the decimal part of the interpolation sample point position information corresponding to the target input sample point, the initial filter coefficient is calculated four times by polynomial calculation to obtain the filter coefficient coef corresponding to the target input sample point S1. That is, the filter coefficient corresponding to the target input sample point S1 is obtained by using the linear approximation method.
[0162] For example, as shown in Table 1, the polynomial coefficients corresponding to the interpolation sample point 3 are a3, b3, c3, d3, e3. When the interpolation sample point 3 is the target interpolation sample point, the initial filter coefficients are a3, b3, c3, d3, e3, the interpolation sample point position information corresponding to the target input sample point is 2.8, and the decimal part of the interpolation sample point position information corresponding to the target input sample point is 0.8. Then, the initial filter coefficients (a3, b3, c3, d3, e3) are calculated four times by polynomial calculation based on 0.8 to obtain the filter coefficient coef corresponding to the target input sample point S1.
[0163] Scenario 2:
[0164] The target input sample point S1 just falls on a certain interpolation sample point in the basic coefficient table of the polyphase filter, then the generation process of the target filter coefficient corresponding to the target input sample point S1 is:
[0165] Step 1, according to the address information pos of the target input sample point S1, calculate the interpolation sample point position information corresponding to the target input sample point S1, and determine the target interpolation sample point according to the interpolation sample point position information corresponding to the target input sample point S1;
[0166] For example, the sample point address information of the target input interpolation sample point S1 is pos=1.5, N=8, then the interpolation sample point position information corresponding to the target input sample point S1 is N×[M-1]+0.5×8=8×[5-1]+4=36. Since the position information corresponding to the interpolation sample point 37 is 36, the target interpolation sample point is the interpolation sample point 37.
[0167] Step 2, selecting a polynomial coefficient corresponding to the interpolation sample point 37 from the polyphase filter basic coefficient table, and using the selected polynomial coefficient as the initial filter coefficient;
[0168] Step 3, according to the decimal information (0) that the interpolation sample point position information corresponding to the target input sample point S1 is 8×[5-1]+4=36, a 4th-order polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient corresponding to the target input sample point S1.
[0169] For example, as shown in Table 1, the polynomial coefficients corresponding to the interpolation sample point 37 are a37, b37, c37, d37, e37. When the interpolation sample point 37 is the target interpolation sample point, the initial filter coefficients are a37, b37, c37, d37, e37. Then, based on 0, the initial filter coefficients (a37, b37, c37, d37, e37) are calculated four times by polynomial calculation to obtain the target filter coefficient coef corresponding to the target input sample point S1.
[0170] The above is an explanation of how to generate target filter coefficients. The following is an explanation of how to generate historical filter coefficients.
[0171] In one embodiment, first, the interpolation sample point position information corresponding to the target input sample point is determined according to the sample point address information pos of the target input sample point, and then the interpolation sample point position information corresponding to the historical sample point is determined according to the interpolation sample point position information corresponding to the target input sample point, the position of the historical sample point in the sample point historical data storage unit, and the target interpolation magnification, and finally the historical filter coefficient corresponding to the historical sample point is determined according to the interpolation sample point position information corresponding to the historical sample point and the polyphase filter basic coefficient table.
[0172] Specifically, first, the product of the target interpolation factor and the difference between the polyphase filter order and 1 is calculated as the first product, the product of the decimal part in the sample point address information pos of the target input sample point and the target interpolation factor is used as the second product, and the sum of the first product and the second product is used as the interpolation sample point position information corresponding to the target input sample point, and then the difference between the interpolation sample point position information corresponding to the target input sample point and the product of the position of the historical sample point and the target interpolation factor is used as the interpolation sample point position information corresponding to the historical sample point. After the interpolation sample point position information corresponding to the historical sample point is determined, the interpolation sample point in the polyphase filter basic coefficient table that is closest to the interpolation sample point position information corresponding to the historical sample point is determined as the target interpolation sample point, the polynomial coefficient corresponding to the target interpolation sample point is used as the initial filter coefficient, and the initial filter coefficient is polynomially calculated based on the decimal part in the interpolation sample point position information corresponding to the historical sample point to obtain the historical filter coefficient.
[0173] The method for calculating the historical filter coefficients can refer to the method for calculating the target filter coefficients, and the repeated parts will not be repeated here.
[0174] For example, Figure 8As shown, the sample point historical data storage unit 34 stores n-1 historical sample points, namely historical sample point Samp1, historical sample point Samp2, historical sample point Samp3...historical sample point Sampn-1. The current target input sample point is Sampn, the position of the historical sample point corresponding to the historical sample point Sampn-1 is 1, the position of the historical sample point corresponding to the historical sample point Samp1 is n-1, the position of the historical sample point corresponding to the historical sample point Samp2 is n-2, and so on.
[0175] If the target input sample point is Sampn, the sample point address information pos=1.35, N=8, then the interpolation sample point position information corresponding to the target input sample point Sampn is 8×[5-1]+0.35×8=34.8, then the interpolation sample point position information of the historical sample point Sampn-1 is 34.8-8=26.8, and the interpolation sample point position information of the historical sample point Sampn-2 is 34.8-2×8=18.8, and so on, the interpolation sample point position information corresponding to each historical sample point can be obtained.
[0176] After obtaining the interpolation sample point position information corresponding to each historical sample point, for each historical sample point, according to the interpolation sample point position information corresponding to the historical sample point, the minimum distance principle is adopted to find the interpolation sample point closest to the historical sample point from the polyphase filter basic coefficient table, and the interpolation sample point found is used as the target interpolation sample point. For example, the interpolation sample point position information of the historical sample point Sampn-1 is 34.8-8=26.8, then the interpolation sample point closest to the historical sample point Sampn-1 is the interpolation sample point 28, and the polynomial coefficients corresponding to the interpolation sample point 28 are determined from the polyphase filter basic coefficient table as a28, b28, c28, d28, e28, and then the initial filter coefficients (a28, b28, c28, d28, e28) are calculated four times by polynomial according to the decimal part 0.6 to obtain the historical filter coefficient coefn-1 corresponding to the historical sample point Sampn-1.
[0177] The method of calculating the historical filter coefficients corresponding to other historical sample points is the same as the above, and the repeated parts will not be repeated.
[0178] In the embodiment of the present application, 2N filter coefficients may be generated.
[0179] In a specific implementation, after the filter coefficient generation unit 32 generates the target filter coefficient and the historical filter coefficient, the target filter coefficient and the historical filter coefficient are sent to the multi-phase filter convolution unit 33 via the control unit 36. At the start time of any playback task, the multi-phase filter convolution unit 33 performs convolution calculation on the received target input sample points, target filter coefficients, historical sample points and historical filter coefficients. The number of convolution calculations is equal to the number of taps of the multi-phase filter in the multi-phase filter convolution unit 33, and the sum of the results of multiple convolution calculations is used as the output sample point, which is output to the second first-in-first-out queue 35 as an output signal for transmission to the audio output device, thereby achieving the purpose of filtering; in the subsequent processing process, the multi-phase filter convolution unit 33 will also obtain the historical sample points stored in the sample point historical data storage unit 34, and perform multiple convolution calculations on the target input sample points, target filter coefficients, historical sample points and historical filter coefficients, and use the sum of the results of multiple convolution calculations as the output sample point until the playback task is completed.
[0180] In the embodiment of the present invention, the number of convolutions of the polyphase filter is 2N, that is, an even number.
[0181] Complete the filter convolution calculation, that is, convolve the current target input sample point, the target filter coefficient corresponding to the target input sample point, the historical sample point, and the historical filter coefficient corresponding to the historical sample point. The convolution calculation can be implemented using a 32bit*28bit multiplier, and the calculation result is saved in a 64bit storage space. Considering the multiplier area and preventing data overflow, the generated polyphase filter coefficient can be represented by 28bit.
[0182] In the embodiment of the present invention, the second FIFO queue 35 may be a 32-level 32-bit wide FIFO queue.
[0183] It should be noted that the sample point history data storage unit 34 in the embodiment of the present invention can perform a data clearing operation under the control of the reset control signal reset to prevent the history data of the previous playback task from affecting the current playback task and causing noise during playback. The reset control signal reset can be triggered at the end of the previous playback task or at the start of the current playback task, and the embodiment of the present invention does not impose any restrictions on this.
[0184] To facilitate understanding, the embodiments of the present application are described below with examples.
[0185] For example, Figure 8As shown, the sample point history data storage unit 34 stores n-1 history sample points, the target input sample point is Sampn, and it is assumed that the interpolation sample point address information corresponding to the target input sample point Sampn in the interpolation queue is 2.25. From Table 1, it can be seen that the target input sample point Sampn is located between the interpolation sample point 3 and the interpolation sample point 4, the distance between the target input sample point Sampn and the interpolation sample point 3 is 0.25, and the distance between the target input sample point Sampn and the interpolation sample point 4 is 0.75. According to the principle of the shortest distance, the interpolation sample point 3 is taken as For the target interpolation sample point, the polynomial coefficients a3, b3, c3, d3 and e3 corresponding to the interpolation sample point 3 are obtained from the polyphase filter basic coefficient table shown in Table 1, a3, b3, c3, d3 and e3 are used as the initial filter coefficients, 0.25 (the decimal part of the interpolation sample point address information 2.25 corresponding to the target input sample point Sampn in the interpolation queue) is used with the initial filter coefficients a3, b3, c3, d3 and e3 to perform four polynomial calculations to obtain the filter coefficient Coefn corresponding to the target input sample point Sampn.
[0186] At the same time, according to the interpolation sample point address information corresponding to the target input sample point Sampn, the interpolation sample point address information corresponding to each historical sample point is calculated, and then the historical filter coefficient corresponding to each historical sample point is calculated in the same way as the target filter coefficient is calculated, and then for each historical sample point stored in the sample point historical data storage unit 34, a convolution operation is performed on the historical sample point and the corresponding historical filter coefficient, and a convolution operation is performed on the target input sample point and the corresponding target filter coefficient, and finally the sum of the convolution operations is used as the output sample point corresponding to the target input sample point, as expressed by the following formula:
[0187] S=Samp1*Coef1+Samp2*Coef2+Samp3*Coef3+……+Sampn-1*Coefn-1+Sa mpn*Coefn
[0188] It should be noted that the historical filter coefficients corresponding to the historical sample points are calculated in real time.
[0189] In an optional embodiment, if Figure 5 As shown, the sampling rate conversion device may further include a fade-in and fade-out unit 37;
[0190] The fade-in and fade-out unit 37 is used to adjust the amplitude value of the output signal composed of the output samples according to a preset amplitude variation rule, so as to produce the effect of gradually weakening or gradually increasing the sound.
[0191] In a specific implementation, the fade unit 37 can be controlled by a switch signal. When the switch signal controls the fade function to be turned on, the fade unit 37 works; when the switch signal controls the fade function to be turned off, the fade unit 37 is bypassed.
[0192] In the above embodiment, the amplitude of the output signal is adjusted by the fade-in and fade-out unit 37 to produce a sound gradually weakening or gradually increasing effect, and can also achieve a muting effect (the output sample amplitude is 0).
[0193] The sampling rate conversion device in the embodiment of the present invention may be an asynchronous sampling rate converter (ASRC). The sampling rate conversion device provided by the embodiment of the present invention may be placed in an audio input device or in an audio output device.
[0194] Based on the same inventive concept, an embodiment of the present application also provides an audio playback system. The principle of solving the problem by the system is similar to the principle of the sampling rate conversion device provided in the present application. The implementation of the system can refer to the implementation of the sampling rate conversion device, and the repeated parts will not be repeated.
[0195] like Fig. 9 As shown in FIG. 1 , it is a schematic diagram of the structure of an audio playback system provided in an embodiment of the present application. Fig. 9 As shown, the audio playback system includes an audio input device 71, an audio output device 72 and a sampling rate conversion device 73 as described above, wherein:
[0196] An audio input device 71, used to send an input signal to the sampling rate conversion device;
[0197] Audio output device 72, for receiving the output signal sent by the sampling rate conversion device.
[0198] Based on the same inventive concept, an embodiment of the present application also provides a sampling rate conversion method. The principle of solving the problem by the method is similar to the principle of the sampling rate conversion device provided by the present application. The implementation of the method can refer to the implementation of the sampling rate conversion device, and the repeated parts will not be repeated.
[0199] like Fig.10 FIG. 1 is a flow chart of a sampling rate conversion method provided in an embodiment of the present application, which specifically includes the following steps:
[0200] S801, sampling an input signal under the control of a decimation factor to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate;
[0201] S802, determining a target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table, and determining a historical filter coefficient corresponding to the historical sample point according to the sample point address information of the target input sample point, wherein the polyphase filter basic coefficient table is used to characterize the correspondence between the interpolation sample point and the polynomial coefficient;
[0202] S803. Perform a convolution operation on the target input sample point, the target filter coefficient, the historical sample point, and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is the target input sample point sampled before the current moment.
[0203] The sampling rate conversion method provided by the embodiment of the present application first samples the input signal under the control of a decimation factor to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate, then determines a target filter coefficient corresponding to the target input sample point based on sample point address information of the target input sample point and based on a polyphase filter basic coefficient table, and determines a historical filter coefficient corresponding to the historical sample point based on the sample point address information of the target input sample point, wherein the polyphase filter basic coefficient table is used to characterize the correspondence between interpolation sample points and polynomial coefficients, and finally performs a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is a target input sample point sampled before a current moment. Since the filter coefficient generation unit in the present application can determine the target filter coefficient corresponding to the target input sample point and the historical filter coefficient corresponding to the historical sample point according to the sample point address information of the target input sample point and the polyphase filter basic coefficient table, the polyphase filter convolution unit performs a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain the output sample point, there is no need to use an interpolation filter to achieve upsampling, and there is no need to use an interpolation filter for downsampling, thereby simplifying the conversion steps and improving the conversion efficiency.
[0204] In one embodiment, before determining the filter coefficient corresponding to the target input sample point based on the target input sample point and the polyphase filter basic coefficient table, the method further includes:
[0205] Determining a sampling mode according to the input sampling rate and the output sampling rate;
[0206] If the sampling mode is upsampling, the filter coefficient corresponding to the target input sample point is determined according to the sample point address information of the target input sample point and based on a first polyphase filter basic coefficient table used to characterize upsampling; if it is determined that the sampling mode is downsampling, the filter coefficient corresponding to the target input sample point is determined according to the sample point address information of the target input sample point and based on a second polyphase filter basic coefficient table used to characterize downsampling.
[0207] In one embodiment, before determining the filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on the second polyphase filter basic coefficient table used to characterize downsampling, the method further includes:
[0208] The filter coefficient generating unit is controlled to read the second polyphase filter basic coefficient table from the external storage area.
[0209] In one embodiment, sampling the input signal under the control of the decimation factor to obtain the target input sample point includes:
[0210] Determining the sampling point address information according to the extraction factor;
[0211] The target input sample point is read from the stored input signal according to the determined sample point address information.
[0212] In one embodiment, determining the target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table includes:
[0213] Determine a target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table;
[0214] Using the polynomial coefficients corresponding to the target interpolation sample points in the polyphase filter basic coefficient table as initial filter coefficients;
[0215] Based on the sample point address information of the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0216] In one embodiment, determining the target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table includes:
[0217] Determine interpolation sample point position information corresponding to the target input sample point according to the sample point address information of the target input sample point and a preset target interpolation magnification;
[0218] According to the interpolation sample point position information corresponding to the target input sample point, the target interpolation sample point is selected from the polyphase filter basic coefficient table by adopting the principle of the shortest distance.
[0219] In one embodiment, performing polynomial calculation on the initial filter coefficient based on the sample address information of the target input sample to obtain the target filter coefficient includes:
[0220] Based on the decimal part of the interpolation sample point position information corresponding to the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
[0221] In one embodiment, determining the historical filter coefficients corresponding to the historical sample points according to the sample point address information of the target input sample points includes:
[0222] Determine the interpolation sample point position information corresponding to the historical sample point according to the interpolation sample point position information corresponding to the target input sample point, the position of the historical sample point in the sample point historical data storage unit, and the target interpolation magnification;
[0223] The filter coefficients corresponding to the historical sample points are determined according to the interpolation sample point position information corresponding to the historical sample points and the polyphase filter basic coefficient table.
[0224] In one embodiment, performing a convolution operation on the target input sample, the target filter coefficient, the historical sample, and the historical filter coefficient to obtain an output sample corresponding to the target input sample includes:
[0225] Performing a convolution operation on the target input sample point and the target filter coefficient, and performing a convolution operation on the historical sample point and the historical filter coefficient;
[0226] The sum of the convolution operation results is used as the output sample point corresponding to the target input sample point.
[0227] In one embodiment, the method further comprises:
[0228] The amplitude value of the output signal composed of the output sample points is adjusted using a preset amplitude variation rule.
[0229] like Fig.11 As shown, it is a complete flow chart of a sampling rate conversion method provided in an embodiment of the present application:
[0230] S901, the operating system loads the corresponding polyphase filter basic coefficients to the specified address MEMORY according to the requirements of the sampling rate conversion specification;
[0231] S902, start the device;
[0232] S903, generating input sample point information according to the extraction factor;
[0233] S904, extracting input sample points according to the input sample point address information to obtain target input sample points;
[0234] S905, storing the target input sample point in the sample point historical data storage unit as a historical sample point;
[0235] S906, generating target filter coefficients and historical filter coefficients according to the address information of the target input sample point and the polyphase filter basic coefficient table;
[0236] S907, obtaining output sample points corresponding to the target input sample points based on the target input sample points, the target filter coefficients, the historical sample points and the historical filter coefficients;
[0237] S906 and S907 are executed in a loop until all taps of the filter have completed the convolution calculation.
[0238] S908, performing fade-in and fade-out processing;
[0239] If the fade switch state is off, the fade is bypassed.
[0240] S909: Complete the calculation of a sampling rate conversion point and output the calculation result.
[0241] S903 to S909 are repeatedly executed until a device shutdown signal is received.
[0242] The sampling rate conversion device provided in the embodiment of the present application is described below in actual testing.
[0243] As shown in Table 2, when the frequency is changed from 44100 Hz to 48000 Hz, 1 kHz, 21 kHz and sweep frequency signals from 20 Hz to 21 kHz are used to test THD+N. The specific simulation results are shown in Fig.15 , Fig.16 , Fig.17 .
[0244]
[0245] Table 2
[0246] As shown in Table 3, when the frequency is changed from 48000 Hz to 44100 Hz, the THD+N is tested using 1 kHz, 21 kHz and a sweep frequency signal of 20 Hz to 21 kHz. The specific simulation results are shown in Fig.12 , Fig.13 , Fig.14 .
[0247]
[0248] Table 3
[0249] The present application is described above with reference to the block diagrams and / or flow charts showing the methods, devices (systems) and / or computer program products according to the embodiments of the present application. It should be understood that a block of the block diagram and / or flow chart diagram and a combination of blocks of the block diagram and / or flow chart diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer and / or other programmable data processing device to produce a machine, so that the instructions executed by the computer processor and / or other programmable data processing device create a method for implementing the functions / actions specified in the block diagram and / or flow chart block.
[0250] Accordingly, the present application may also be implemented with hardware and / or software (including firmware, resident software, microcode, etc.). Furthermore, the present application may take the form of a computer program product on a computer-usable or computer-readable storage medium, which has a computer-usable or computer-readable program code implemented in the medium, for use by an instruction execution system or in conjunction with an instruction execution system. In the context of the present application, a computer-usable or computer-readable medium may be any medium that may contain, store, communicate, transmit, or convey a program for use by an instruction execution system, device, or apparatus, or in conjunction with an instruction execution system, device, or apparatus.
[0251] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A sampling rate conversion device, characterized in that: It includes a signal sampling unit, a filter coefficient generating unit and a polyphase filter convolution unit; The signal sampling unit is used to sample the input signal under the control of a decimation factor to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate; The filter coefficient generating unit is used to determine the target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on the polyphase filter basic coefficient table, and determine the historical filter coefficient corresponding to the historical sample point according to the sample point address information of the target input sample point, wherein the polyphase filter basic coefficient table is used to characterize the corresponding relationship between the interpolation sample point and the polynomial coefficient; The polyphase filter convolution unit is used to perform a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is the target input sample point sampled by the signal sampling unit before the current moment.
2. The device according to claim 1, characterized in that It also includes a first storage unit and a second storage unit, the data in the polyphase filter basic coefficient table is in an even symmetric format, and the polyphase filter basic coefficient table includes a first polyphase filter basic coefficient table representing upsampling and a second polyphase filter basic coefficient table representing downsampling; The first storage unit is used to store a set of symmetric data in the first polyphase filter basic coefficient table; The second storage unit is used to store a group of symmetric data in the second polyphase filter basic coefficient table.
3. The device according to claim 2, characterized in that Also includes a control unit; The control unit is configured to determine a sampling mode according to the input sampling rate and the output sampling rate; if the sampling mode is upsampling, control the filter coefficient generation unit to determine the filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on the first polyphase filter basic coefficient table stored in the first storage unit; if it is determined that the sampling mode is downsampling, control the filter coefficient generation unit to determine the filter coefficient corresponding to the target input sample point according to the target input sample point and based on the second polyphase filter basic coefficient table stored in the second storage unit.
4. The device according to claim 3, characterized in that Before controlling the filter coefficient generating unit to determine the filter coefficient corresponding to the target input sample point according to the target input sample point and based on the second polyphase filter basic coefficient table stored in the second storage unit, the control unit is further configured to: The filter coefficient generation unit is controlled to read the second polyphase filter basic coefficient table from an external storage area.
5. The device according to claim 1, characterized in that The signal sampling unit includes a first first-in first-out queue and an address generation subunit; The first first-in-first-out queue is used to store input signals sent by the audio input device; The address generation subunit is used to determine the sample point address information according to the extraction factor, and read the target input sample point from the input signal stored in the first FIFO queue according to the determined sample point address information.
6. The device according to claim 5, characterized in that Also includes a sample point historical data storage unit; The sample point historical data storage unit is used to store the target input sample points sampled by the signal sampling unit, and use the target input sample points as historical sample points.
7. The device according to claim 5, characterized in that The filter coefficient generating unit is specifically used for: Determine a target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table; Using the polynomial coefficients corresponding to the target interpolation sample points in the polyphase filter basic coefficient table as initial filter coefficients; Based on the sample point address information of the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
8. The device according to claim 7, characterized in that The filter coefficient generating unit is specifically used for: Determine interpolation sample point position information corresponding to the target input sample point according to the sample point address information of the target input sample point and a preset target interpolation magnification; According to the interpolation sample point position information corresponding to the target input sample point, the target interpolation sample point is selected from the polyphase filter basic coefficient table by adopting the principle of the shortest distance.
9. The device according to claim 8, characterized in that The filter coefficient generating unit is specifically used for: Based on the decimal part of the interpolation sample point position information corresponding to the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
10. The device according to claim 8, characterized in that The filter coefficient generating unit is specifically used for: Determine the interpolation sample point position information corresponding to the historical sample point according to the interpolation sample point position information corresponding to the target input sample point, the position of the historical sample point in the sample point historical data storage unit, and the target interpolation magnification; The historical filter coefficients corresponding to the historical sample points are determined according to the interpolation sample point position information corresponding to the historical sample points and the polyphase filter basic coefficient table.
11. The device according to claim 6, characterized in that The polyphase filter convolution unit is specifically used for: Performing a convolution operation on the target input sample point and the target filter coefficient, and performing a convolution operation on the historical sample point and the historical filter coefficient; The sum of the convolution operation results is used as the output sample point corresponding to the target input sample point.
12. The device according to claim 1, characterized in that Also included is a second first-in, first-out queue; The second first-in-first-out queue is used to store the generated output samples in sequence.
13. The device according to any one of claims 1 to 12, characterized in that: Also includes a fade unit; The fade-in and fade-out unit is used to adjust the amplitude value of the output signal composed of the output sample points by adopting a preset amplitude variation rule.
14. An audio playback system, characterized in that: The method comprises an audio input device, an audio output device and a sampling rate conversion device as claimed in any one of claims 1 to 13, wherein: The audio input device is used to send an input signal to the sampling rate conversion device; The audio output device is used to receive the output signal sent by the sampling rate conversion device.
15. A sampling rate conversion method, characterized in that: Applied to the sampling rate conversion device according to any one of claims 1 to 13, the method comprises: Under the control of a decimation factor, sampling the input signal to obtain a target input sample point, wherein the decimation factor is determined by an input sampling rate and an output sampling rate; Determine, according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table, a target filter coefficient corresponding to the target input sample point, and determine, according to the sample point address information of the target input sample point, a historical filter coefficient corresponding to the historical sample point, wherein the polyphase filter basic coefficient table is used to characterize the correspondence between the interpolation sample point and the polynomial coefficient; A convolution operation is performed on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point, wherein the historical sample point is a target input sample point sampled before the current moment.
16. The method according to claim 15, characterized in that Before determining the filter coefficient corresponding to the target input sample point based on the target input sample point and the polyphase filter basic coefficient table, the method further includes: Determining a sampling mode according to the input sampling rate and the output sampling rate; If the sampling mode is upsampling, the filter coefficient corresponding to the target input sample point is determined according to the sample point address information of the target input sample point and based on a first polyphase filter basic coefficient table used to characterize upsampling; if it is determined that the sampling mode is downsampling, the filter coefficient corresponding to the target input sample point is determined according to the sample point address information of the target input sample point and based on a second polyphase filter basic coefficient table used to characterize downsampling.
17. The method according to claim 16, characterized in that: Before determining the filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on the second polyphase filter basic coefficient table used to characterize downsampling, the method further includes: The filter coefficient generating unit is controlled to read the second polyphase filter basic coefficient table from the external storage area.
18. The method according to claim 15, characterized in that The step of sampling the input signal under the control of the decimation factor to obtain the target input sample point comprises: Determining the sampling point address information according to the extraction factor; The target input sample point is read from the stored input signal according to the determined sample point address information.
19. The method according to claim 18, characterized in that The step of determining the target filter coefficient corresponding to the target input sample point according to the sample point address information of the target input sample point and based on a polyphase filter basic coefficient table includes: Determine a target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table; Using the polynomial coefficients corresponding to the target interpolation sample points in the polyphase filter basic coefficient table as initial filter coefficients; Based on the sample point address information of the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
20. The method of claim 19, wherein: The step of determining the target interpolation sample point according to the sample point address information of the target input sample point and the position information of the interpolation sample point in the polyphase filter basic coefficient table comprises: Determine interpolation sample point position information corresponding to the target input sample point according to the sample point address information of the target input sample point and a preset target interpolation magnification; According to the interpolation sample point position information corresponding to the target input sample point, the target interpolation sample point is selected from the polyphase filter basic coefficient table by adopting the principle of the shortest distance.
21. The method of claim 20, wherein: The step of performing polynomial calculation on the initial filter coefficient based on the sample point address information of the target input sample point to obtain the target filter coefficient comprises: Based on the decimal part of the interpolation sample point position information corresponding to the target input sample point, a polynomial calculation is performed on the initial filter coefficient to obtain the target filter coefficient.
22. The method of claim 20, wherein: The determining, according to the sample point address information of the target input sample point, the historical filter coefficient corresponding to the historical sample point comprises: Determine the interpolation sample point position information corresponding to the historical sample point according to the interpolation sample point position information corresponding to the target input sample point, the position of the historical sample point in the sample point historical data storage unit, and the target interpolation magnification; The filter coefficients corresponding to the historical sample points are determined according to the interpolation sample point position information corresponding to the historical sample points and the polyphase filter basic coefficient table.
23. The method of claim 15, wherein: The step of performing a convolution operation on the target input sample point, the target filter coefficient, the historical sample point and the historical filter coefficient to obtain an output sample point corresponding to the target input sample point includes: Performing a convolution operation on the target input sample point and the target filter coefficient, and performing a convolution operation on the historical sample point and the historical filter coefficient; The sum of the convolution operation results is used as the output sample point corresponding to the target input sample point.
24. The method according to any one of claims 15 to 23, characterized in that: The method further includes: The amplitude value of the output signal composed of the output sample points is adjusted using a preset amplitude variation rule.
Citation Information
Cited By
Audio data processing system
CN120751316A
Processing system for audio data
CN120751316B
Method for reducing resource overhead in data resampling process
CN121541820A