WO2018120545A1 - Method and device for testing latency of audio loop - Google Patents

Method and device for testing latency of audio loop Download PDF

Info

Publication number
WO2018120545A1
WO2018120545A1 PCT/CN2017/082238 CN2017082238W WO2018120545A1 WO 2018120545 A1 WO2018120545 A1 WO 2018120545A1 CN 2017082238 W CN2017082238 W CN 2017082238W WO 2018120545 A1 WO2018120545 A1 WO 2018120545A1
Authority
WO
WIPO (PCT)
Prior art keywords
sine wave
amplitude
time
pcm
peak
Prior art date
Application number
PCT/CN2017/082238
Other languages
French (fr)
Chinese (zh)
Inventor
曹海恒
谭利文
孙伟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201780009092.1A priority Critical patent/CN108702568B/en
Publication of WO2018120545A1 publication Critical patent/WO2018120545A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04RLOUDSPEAKERS, MICROPHONES, GRAMOPHONE PICK-UPS OR LIKE ACOUSTIC ELECTROMECHANICAL TRANSDUCERS; DEAF-AID SETS; PUBLIC ADDRESS SYSTEMS
    • H04R3/00Circuits for transducers, loudspeakers or microphones

Definitions

  • the present application relates to the field of testing technologies, and in particular, to a method and device for testing an audio loop delay.
  • the audio processing process of Android or IOS operating system is mainly composed of two parts: recording thread and playing thread.
  • the flow of the recording thread is: first input the sound from the microphone, then The analog to digital converter (ADC) is converted into audio data, and then the audio data is transmitted to the system audio service unit via the bus and the hardware and software driver, and finally the audio data is transmitted to the user via the first audio transmission unit.
  • the process of playing the thread is: the second audio transmission unit reads the audio data from the buffer of the user application, and transmits the read audio data to the system audio service unit, and the system audio service unit will be driven by the hardware and software and the Bus.
  • the audio data is transmitted to a digital to analog converter (DAC), which converts the audio data into analog data, and the analog data is played through a speaker.
  • DAC digital to analog converter
  • the audio loop delay refers to the time taken for the sound to input from the microphone of the smart terminal to the output of the speaker.
  • the present application provides a method and apparatus for testing an audio loop delay to test an audio loop delay inside a terminal.
  • the present application provides a method for testing an audio loop delay, including: a terminal opening a preset play thread, where the play thread is configured to read a preset audio file from a buffer of the terminal, and The speaker of the terminal plays the preset audio file; the terminal starts a preset recording thread, and the recording thread is used to record a preset audio file played by the speaker through a microphone of the terminal; Determining an audio loop delay of the terminal according to the first time information that the playing thread plays the preset audio file and the second time information that the recording thread records the preset audio file, where the audio loop Time delay means that the sound is input from the microphone of the terminal. Time consuming to output from the speaker of the terminal.
  • the delay of the internal audio loop of the terminal can be determined by adopting the preset audio file of the present application.
  • the terminal according to the first time information of playing the preset audio file by the playing thread, and the second time of recording, by the recording thread, the preset audio file, Determining, by the terminal, determining, by the terminal, the first time information of the target data in the preset audio file; the terminal determining, by the recording thread, the pre-recording The second time information of the target data in the audio file is set; the terminal determines the audio loop delay of the terminal according to the difference between the second time information and the first time information.
  • the audio loop delay is calculated by using the target data of the preset audio file as a reference, which can make the calculation of the audio loop delay more efficient.
  • the preset audio file is a sine wave pulse code modulation PCM file
  • the sine wave PCM file is a sine wave and a second pass through the first amplitude
  • the amplitude sine wave is obtained by PCM processing
  • the target data of the preset audio file is a sampling value corresponding to the first peak of the second amplitude sine wave.
  • the sample values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ in play time by a first duration, and The playing time of the sampling value corresponding to the sine wave of the first amplitude is earlier than the playing time of the sampling value corresponding to the sine wave of the second amplitude;
  • Determining, by the terminal, that the playing thread plays the first time information of the target data in the preset audio file including: the terminal recording time information that the playing thread starts playing the preset audio file; Determining, by the playing thread, the time information of playing the preset audio file, the sine wave of the first amplitude, and the sampling time corresponding to the sine wave of the second amplitude are different in the playing time, determining the terminal And starting to play time information of the sampling value corresponding to the sine wave of the second amplitude; the terminal starts to play the time information of the sampling value corresponding to the sine wave of the second amplitude according to the terminal, and the second amplitude sine a period of the wave, determining first time information of the sampling value corresponding to the first peak of the second amplitude sine wave played by the playing thread.
  • the preset audio file includes multiple frames of audio data, and each frame of audio data includes multiple PCM samples, and each PCM sample Corresponding to a PCM sample value;
  • the terminal Determining, by the terminal, that the recording thread records the second time information of the target data in the preset audio file, the terminal: determining, by the terminal, the audio to which the PCM sample of the first peak of the second amplitude sine wave belongs a data frame; the terminal searches for a time from the audio data frame to which the PCM sample of the first peak belongs to the time that the audio data frame belongs to the recording thread, and the audio data frame Corresponding relationship with the time of reaching the recording thread is determined according to the time of each frame of the audio data in the preset audio file and the time of reaching the recording thread; the terminal corresponding to the first peak of the sine wave of the second amplitude a sample number of the PCM sample, a length of the audio data frame, and a frequency of PCM sampling the sine wave of the second amplitude, determining a PCM sample of the first peak of the second amplitude sine wave relative to the assigned audio The offset time of the data frame to the recording thread time; the terminal according to the time when the belonging audio data frame arrives at
  • the terminal determines, by the terminal, an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs, including: a left gradient and a right gradient of each PCM sample in the preset audio file, the left gradient being a difference between a sample value of a PCM sample and a sample value of an adjacent left PCM sample, the right gradient being a PCM a difference between the sampled value of the sample and the sampled value of the adjacent right PCM sample; the terminal searches for PCM samples whose left gradient and right gradient are both greater than zero from the PCM samples of the preset audio file, and establishes a peak PCM sample ???collecting, from the set of peak PCM samples, searching for a PCM sample of a first peak of a second amplitude sine wave, wherein the PCM sample of the first peak of the second amplitude sine wave corresponds to The sampled value is greater than the sampled value of the adjacent left peak PCM sample, equal
  • the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time;
  • the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave;
  • the FrameL represents the length of the audio data frame, the % represents the remainder, and
  • the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
  • an apparatus for testing an audio loop delay comprising a processor and a memory; the processor, configured to read code in the memory for execution: enabling a preset playback a thread, the play thread is configured to read a preset audio file from a buffer of the device, and play the preset audio file via a speaker of the device; enable a preset recording thread, and the recording thread uses Recording a preset audio file played by the speaker through a microphone of the device; playing first time information of the preset audio file according to the playing thread, and recording, by the recording thread, the preset audio file The second time information determines an audio loop delay of the device, the audio loop delay being a time consuming time from the microphone input of the device to the output of the speaker of the device.
  • the processor is configured to play the first time information of the preset audio file according to the playing thread, and the recording thread records the preset audio file Determining, by the second time information, the delay time of the audio loop of the device, specifically, determining: determining, by the playing thread, the first time information of the target data in the preset audio file; determining that the recording thread records the preset Second time information of the target data in the audio file; determining an audio loop delay of the device according to a difference between the second time information and the first time information.
  • the preset audio file is a sine wave pulse code modulation PCM file
  • the sine wave PCM file is a sine wave and a second pass through the first amplitude
  • the amplitude sine wave is obtained by PCM processing
  • the target data of the preset audio file is a sampling value corresponding to the first peak of the second amplitude sine wave.
  • the sample values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ in play time by a first duration, and The playing time of the sampling value corresponding to the sine wave of the first amplitude is earlier than the playing time of the sampling value corresponding to the sine wave of the second amplitude;
  • the processor When determining, by the processor, the first time information of the target data in the preset audio file, the processor is specifically configured to: record time information that the playing thread starts playing the preset audio file; The playing thread starts time information for playing the preset audio file, the sine wave of the first amplitude, and the sine wave of the second amplitude a first time period in which the corresponding sampled value is different in the playing time, determining time information of the sampling value corresponding to the sine wave of the second amplitude that is started by the device; and starting to play the second amplitude according to the device The time information of the sampled value corresponding to the sine wave and the period of the second amplitude sine wave determine the first time information of the sampling value corresponding to the first peak of the second amplitude sine wave played by the playing thread.
  • the preset audio file includes multi-frame audio data, each frame of audio data includes multiple PCM samples, and each PCM sample corresponds to one PCM sample value;
  • the processor is specifically configured to: determine that the PCM sample of the first peak of the second amplitude sine wave belongs to Audio data frame; from the correspondence between the audio data frame and the time of reaching the recording thread, searching for the audio data frame to which the PCM sample of the first peak belongs to correspond to the time of reaching the recording thread, the audio data frame and Corresponding relationship of the time of reaching the recording thread is determined according to the audio data of each frame in the preset audio file and the time of reaching the recording thread; the sample of the PCM sample corresponding to the first peak of the sine wave of the second amplitude a number, a length of the audio data frame, and a frequency of PCM sampling the sine wave of the second amplitude, determining that the PCM sample of the first peak of the second amplitude sine wave arrives at the recording with respect to the assigned audio data frame The offset time of the thread time; determining the recording thread recording station according to the time when the belonging audio data frame arrives at the recording
  • a fifth possible implementation manner when the determining, by the processor, the audio data frame to which the PCM sample of the first peak in the second amplitude sine wave belongs, Calculating a left gradient and a right gradient of each PCM sample in the preset audio file, the left gradient being a difference between a sample value of a PCM sample and a sample value of an adjacent left PCM sample, the right gradient finger The difference between the sampled value of a PCM sample and the sampled value of the adjacent right PCM sample; from the PCM samples of the preset audio file, find a PCM sample whose left gradient and right gradient are both greater than zero, and establish a peak PCM sample set Obtaining, from the set of peak PCM samples, a PCM sample of a first peak of a second amplitude sine wave, wherein a sample value corresponding to a PCM sample of the first peak of the second amplitude sine wave is greater than The sampled value of the adjacent left peak PCM sample is equal to the sample value of
  • the processor determines a PCM sample of the first peak in the sine wave of the second amplitude relative to the assigned audio data
  • the offset time of the frame arrival time of the recording thread meets the following formula:
  • the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time;
  • the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave;
  • the FrameL represents the length of the audio data frame, the % represents the remainder, and
  • the Samplerate represents PCM sampling of the second amplitude sine wave by the device Frequency of.
  • a computer readable storage medium for storing software instructions for performing the functions of any of the above first aspect, the first aspect of the present application, comprising the first Aspect, the program designed by any of the methods of the first aspect.
  • the terminal first starts the playing thread and the recording thread, the playing thread will play the preset audio file, and the recording thread will record the preset audio file played by the playing thread, and the terminal records and plays the preset audio.
  • the information and the second time information can determine the audio loop delay inside the terminal.
  • FIG. 1 is a flowchart of processing audio data according to an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of hardware of a terminal according to an embodiment of the present disclosure
  • FIG. 3 is a schematic flowchart diagram of a method for testing an audio loop delay according to an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of a test audio loop delay provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a sine wave corresponding to a PCM file provided by the present application.
  • FIG. 6 is another schematic diagram of a test audio loop delay provided by the present application.
  • FIG. 7 is a schematic structural diagram of an apparatus for testing an audio loop delay provided by the present application.
  • FIG. 8 is a schematic structural diagram of an apparatus for testing an audio loop delay provided by the present application.
  • Terminal It can be a mobile terminal (such as a mobile phone, a portable computer, and a wearable device), or it can be a non-mobile terminal (for example, a fixed computer, a television, etc.).
  • the terminal includes at least a microphone and a speaker for processing audio data, and mainly recording audio data (such as user sound) from a microphone input, and processing, and outputting by the speaker.
  • the audio processing process is mainly composed of a recording thread and a playing thread.
  • Recording thread Refer to Figure 1.
  • the processing flow is to input analog audio data (such as user sound) from the microphone, convert it to digital audio data through analog to digital converter (ADC), via bus Bus and soft.
  • ADC analog to digital converter
  • the hardware driver transmits the digital audio data to the system audio service unit, and then transmits the digital audio data to the buffer through the first audio transmission unit.
  • Play thread refer to FIG. 1 , the processing flow is: the second audio transmission unit reads the digital audio data from the buffer, and transmits the read digital audio data to the system audio service unit, and the system audio service unit is softened.
  • the hardware driver and the Bus transfer the digital audio data to a Digital to Analog Converter (DAC), which converts the digital audio data into analog audio data for playback via the speaker.
  • DAC Digital to Analog Converter
  • the driving in the recording thread and the playing thread, the driving may be ALSA
  • the system audio service unit may be AudioFinger
  • the first audio transmission unit may be Audio Record
  • the second audio transmission unit may be For Audio Track or Media palyer.
  • the system audio service unit and the first audio transmission unit may further include a Binder unit, and the system audio service unit and the second audio transmission unit may also be included. Includes a Binder unit.
  • Audio loop delay refers to the delay of audio data input from the terminal's microphone to the speaker output from the terminal; the delay is mainly composed of the recording delay of the recording thread and the playback delay of the playback thread.
  • Sinusoidal Pulse Code Modulation (PCM) file a file obtained by PCM processing a sine wave of a first amplitude and a sine wave of a second amplitude, the PCM processing comprising: sampling and quantizing a sine wave And encoding three processes; the PCM file includes multi-frame audio data, each frame of audio data includes a plurality of PCM samples (eg, one frame of audio data may include 640 PCM samples), and each PCM sample corresponds to a sine wave A sample value.
  • PCM Sinusoidal Pulse Code Modulation
  • PCM sample a sample point passing through a sine wave of a first amplitude or a sine wave of a second amplitude, quantized and The data obtained after encoding.
  • the method and device for testing the audio loop delay provided in the embodiment of the present application can be applied to the audio loop delay in the test terminal.
  • the application scenario of the application is introduced. With the rapid development of the Internet, more and more terminals are provided. Support real-time audio scenes, such as K songs, DJs, and games. In these real-time audio scenarios, the audio data that the user wishes to input to the terminal can be output from the terminal as soon as possible. Based on this, the present application provides a method and apparatus for testing an audio loop delay to test an audio loop delay of a terminal.
  • FIG. 2 shows a hardware structure of the terminal 200, as shown in FIG. 2, which may include: a processor 201, a memory 202, a display device 203, an input device 204, an audio circuit 205, Microphone 206 and speaker 207.
  • the memory 202, the display device 203, and the input device 204 are all connected to the processor 201.
  • the memory 202 is configured to store an executable program, including the program for testing the audio loop delay provided by the present application
  • the memory 202 includes a memory and an external memory, and the memory may be a random access memory (RAM), a read only memory (ROM), and Cache (CACHE), etc.
  • the external storage can be a hard disk, a CD, a USB disk, a floppy disk or a tape drive.
  • the executable program is usually stored on the external memory, and the processor 201 loads the executable program from the external memory into the memory before executing the program, for example, a program for performing the method for testing the audio loop delay provided by the present application.
  • the components of the terminal 200 will be specifically described below with reference to FIG. 1 :
  • the processor 201 is a control center of the terminal 200, which connects various parts of the terminal by various interfaces and lines, by running or executing a program (or "unit") stored in the memory 202, and calling the memory stored in the memory 202.
  • the data, various functions and data processing of the terminal 200 are performed, thereby performing overall monitoring of the terminal 200.
  • the processor 201 may include at least one processing unit that integrates processing and wireless communication functions.
  • the processor 201 may also include an application processor and a modem.
  • the application processor mainly processes the operating system. User interface and applications, etc. Modems are primarily used for wireless communication.
  • the memory 202 mainly includes a storage program area and a storage data area.
  • the storage program area may store an operating system of the terminal (for example, an Android operating system, an IOS operating system, etc.), an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.), And an application program of the method for testing the audio loop delay involved in the embodiment of the present application.
  • the storage data area may store data created according to the use of the terminal 200, including related setting information or usage information of the method of testing the audio loop delay involved in the present application.
  • the display device 203 is configured to display information input by the user, information provided to the user, and various menus of the terminal 200, including various information about a method for testing an audio loop delay involved in the embodiment of the present application, such as parameter configuration information. And test results display information and so on.
  • the input device 204 is configured to receive the input digits, the character information, and various input commands, such as the start test command and the stop test command of the method for testing the audio loop delay provided by the present application.
  • Input device 204 can also include a touch panel and/or other type of input device.
  • the touch panel may also be referred to as a touch screen, and may collect a touch operation on or near the user (for example, a touch operation on or near the user using a finger, a stylus, or the like).
  • Other types of input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons and switch buttons, etc.), a mouse, a trackball, and a joystick.
  • the audio circuit 205 is configured to perform acoustic/electrical conversion on the microphone 206, amplify the obtained analog audio data, convert it into digital audio data, perform PCM encoding, and transmit the encoded digital audio data to the processor 201. Or, The digital audio data transmitted by the processor 201 is subjected to PCM decoding, the decoded digital audio data is converted into analog audio data, and then power amplification is performed, and the speaker 207 performs electrical/acoustic conversion to push the speaker to sound.
  • the internal structure of the terminal 200 shown in FIG. 2 does not constitute a limitation to the terminal, and may include more or less parts than those illustrated, or combine some components, or different component arrangements.
  • the terminal 200 when it communicates with the outside world in a wireless manner, it may further include a radio frequency (RF) circuit and a connected antenna, a wireless fidelity (WIFI) module, and a connected antenna.
  • RF radio frequency
  • WIFI wireless fidelity
  • the terminal 200 may further include a sensor and a power source for supplying power thereto, etc., and are not enumerated here.
  • the present application provides a method for testing an audio loop delay.
  • the terminal involved in the method may be specifically the terminal 200.
  • the speaker may be specifically the speaker 207, and the microphone may be specifically the microphone 206.
  • the audio loop delay is composed of the recording delay of the recording thread and the playback delay of the playback thread.
  • the main principle of the method is: preset audio file, the preset audio file is preset.
  • the terminal In the terminal (such as placed in the buffer in Figure 1 above, or other storage area, and then load the preset audio file into the buffer when performing the test), start the playback thread, play the preset audio file, The first time information of playing the preset file is recorded; at the same time, the recording thread is started, and the recording thread records the preset audio file played by the playing thread to obtain the second time information of the recorded audio file. Then, based on the first time information and the second time information, the delay of the audio loop is determined, for example, the audio loop delay is set as the difference between the second time information and the first time information.
  • Step S31 The terminal starts a preset playing thread.
  • the processing process of the playing thread is: the second audio transmission unit reads the preset audio file from the buffer, and transmits the read preset audio file to the system audio service unit, the system audio.
  • the service unit then transmits the preset audio file to the DAC via the hardware and software driver and the Bus, and the DAC converts the preset audio file into an analog file for electrical/audio conversion and plays through the speaker.
  • Step S32 The terminal starts a preset recording thread.
  • the processing process of the recording thread is: the sound played by the input speaker in the microphone is converted by sound/electricity, and the analog file can be obtained at this time, and the analog file can be converted into a digital file by ADC conversion.
  • the digital file at this time is a preset audio file; the preset audio file is transmitted to the first audio transmission unit via the driving and system audio service unit, and the first audio transmission unit writes the preset audio file to the buffer. .
  • Step S33 The terminal determines the audio loop delay of the terminal according to the first time information of the preset audio file played by the playing thread and the second time information of the audio file recorded by the recording thread.
  • a target data can be determined in a preset audio file, which can be used as a reference for calculating an audio loop delay. Then, determining a first time information that the playing thread starts playing the target data, and a second time information that the recording thread records the target data, and finally, a difference between the second time information and the first time information as the audio of the terminal Loop delay; for example, the second time information is 10:59:50,35 milliseconds, and the first time information is 10:59:50,40 milliseconds, then the audio loop delay of the terminal is 5 milliseconds.
  • first time information and the second time information described above are merely for distinguishing different time information, and are not to be understood as indicating or implying relative importance, nor as indicating or suggesting order.
  • the step S31 to the step S33 do not limit the sequence before and after the terminal performs the steps of the present application, and the method provided by the present application may be performed in the order of step S31, step S32, and step S33.
  • the method of the present application can be performed in the order of step S32, step S31, and step S33, all within the scope of protection of the present application.
  • the recording thread may be first executed in step S32, and then the step S31 is executed to perform the playback. Thread.
  • the terminal first starts the playing thread and the recording thread, the playing thread will play the preset audio file, and the recording thread will record the preset audio file played by the playing thread, and the terminal records and plays the preset audio.
  • the first time information of the file and the second time information of the preset audio file are recorded; finally, the terminal determines the audio loop delay inside the terminal according to the first time information and the second time information.
  • the preset audio file may be a sine wave PCM file; wherein the sine wave PCM file performs PCM processing on a sine wave of a first amplitude and a sine wave of a second amplitude
  • the obtained file, the PCM processing includes three processes of sampling, quantizing, and encoding a sine wave.
  • the amplitude of the sine wave of the first amplitude may be A
  • the amplitude of the sine wave of the second amplitude may be 2A
  • the sine wave and the second amplitude of the first amplitude may be the same or different, for example, the frequency of both may be 440HZ.
  • the sampling value corresponding to the first peak of the second amplitude sine wave in the sine wave PCM file may be specifically used as the target data to calculate the audio loop delay, and the process is as follows:
  • the terminal determines that the playing thread plays the first time information of the sample value corresponding to the first peak of the sine wave of the second amplitude.
  • the sampling values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively may be different in the playing time by the first time length ⁇ t, and the sine wave corresponding to the first amplitude corresponds to The playing time of the sampled value is earlier than the playing time of the sampled value corresponding to the sine wave of the second amplitude.
  • the sample value of the sine wave of the first amplitude is played first, and after the sine wave 5S of the first amplitude is played, the sample value corresponding to the sine wave of the second amplitude is played.
  • the calculation process is as follows: recording the time information that the playing thread starts playing the preset audio file (for example, starting the playing of the preset audio file at time T1), and then according to the time T1, the first amplitude
  • the first time duration (for example, ⁇ t) of the sine wave and the sine wave of the second amplitude are different in the playing time, and time information (for example, T1+ ⁇ t) corresponding to the acquired value of the sine wave that starts playing the second amplitude is calculated; Determining, according to T1+ ⁇ t, and a period T of the sine wave of the second amplitude, the first time information of the sampling value corresponding to the first peak of the sine wave of the second amplitude played by the playing thread; as can be seen from FIG.
  • the first time information for playing the sample value corresponding to the first peak of the second amplitude sine wave is T1 + ⁇ t + 1/4T.
  • T1+ ⁇ t can also be directly used as the first time information of the sample value corresponding to the first peak of the second amplitude sine wave. Also within the scope of protection of this application.
  • the terminal determines that the recording thread records the second time information of the sample value corresponding to the first peak of the sine wave of the second amplitude, as shown in FIG. 6.
  • Step S61 determining an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs;
  • the preset audio file may include multi-frame audio data.
  • the terminal records the time when the audio data of each frame in the preset audio file reaches the recording thread, and forms a correspondence relationship between the frame index and the time, such as MAP.
  • MAP ⁇ (1st frame audio data, Time1), (2nd frame audio data, Time2), (3rd frame audio data, Time3)» ⁇ .
  • Timel, Time2 togetherTimeN is the corresponding audio data of each frame up to the recording thread. time.
  • each frame of audio data may include a plurality of PCM samples (eg, typically one frame of audio data includes 640 PCM samples), each PCM sample corresponding to a PCM sample value.
  • PCM samples eg, typically one frame of audio data includes 640 PCM samples
  • the left gradient GradientL[n] and the right gradient GradientR[n] for each PCM sample can be found.
  • Sample[n] represents the current PCM sample
  • Sample[n-1] represents the left adjacent PCM sample in the current PCM sample in one frame of audio data
  • Sample[n+1] represents one frame of audio data.
  • the PCM sample immediately adjacent to the current PCM sample.
  • both the left gradient and the right gradient of one PCM sample are greater than 0, it indicates that the PCM sample is an acquisition value corresponding to a peak representing a sine wave;
  • the peak PCM sample set includes a peak set index set S I and a wave peak set S V ; wherein the peak set index set S I represents the PCM number of each peak sample, and the wave peak set S V represents the size of the sample value corresponding to the peak ;
  • a specific implementation may be: an iterative wave peak set S V , and a peak gradient G[j].
  • V[j] represents the sample value corresponding to the current peak
  • V[j-1] represents the sample value corresponding to the left peak adjacent to the current peak
  • the audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs is determined.
  • FrameL may specifically include the number of PCM samples per frame.
  • Step S62 Searching, from the correspondence relationship MAP between the audio data frame and the time of the recording thread, the time at which the audio data frame to which the PCM sample of the first peak belongs belongs to the recording thread;
  • Step S63 the sample number of PCM samples in the first peak amplitude of the second sine wave corresponds according to I j, the audio data frame length FrameL PCM samples and the frequency of the second sinusoidal amplitude, determined An offset time of the PCM sample of the first peak of the second amplitude sine wave relative to the assigned audio data frame to the recording thread time;
  • the terminal determines the offset time of the PCM sample of the first peak of the second amplitude sine wave relative to the time at which the assigned audio data frame reaches the recording thread, which meets the following formula:
  • said T represents an offset time of a PCM sample of a first peak of said second amplitude sine wave relative to a time of arrival of said belonging audio data frame; said Ij representing said second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
  • I j is 10014
  • FrameL is 1000
  • I j and FrameL can be obtained as 14, and it can be seen that I j is the 14th PCM sample in the belonging data frame
  • 14*1/Samplerate is the offset time of I j in the audio data frame to which it belongs
  • Samplerate represents the frequency of PCM sampling
  • 1/Samplerate represents the period of PCM sampling, ie, how long to collect a PCM per interval Sample
  • 14*1/Samplerate is the time information for collecting the 14th PCM sample in the current audio data frame.
  • Step S64 Determine, according to the time when the belonging audio data frame arrives at the recording thread and the offset time, the recording time to record the second time information of the sample value corresponding to the first peak in the sine wave of the second amplitude.
  • the time when the audio data frame to which the first peak of the second amplitude sine wave belongs to the recording thread and the calculated programming time may be specifically summed as the first peak in the second amplitude sine wave.
  • Tloop TimeFrameIndex+Ij%FrameL*1/Samplerate-(T1+ ⁇ t+1/4T);
  • TimeFrameIndex+Ij%FrameL*1/Samplerate represents the second time information of the recording thread starting to record the first peak of the second amplitude sine wave, wherein TimeFrameIndex represents the first peak of the second amplitude sine wave belongs to When the audio data frame reaches the recording thread, Ij%FrameL*1/Samplerate represents the offset time of the first peak of the second amplitude amplitude sine wave within the frame of the belonging data; (T1+ ⁇ t+1/4T) Representing the first time when the playing thread starts playing the first peak of the second amplitude sine wave, T1 is the time to start playing the first amplitude sine wave, and ⁇ t represents the second amplitude sine wave and the first amplitude sine wave in the playing time The time difference, 1/4T represents the time from the start of playing the second amplitude sine wave to the play to the peak.
  • an apparatus 700 for testing an audio loop delay including a processor 701 and a memory 702;
  • the memory 702 is used to store the program instructions of the method for testing the audio loop delay.
  • the memory 702 may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD). It can also be a volatile memory such as a random-access memory (RAM).
  • a memory is any other medium that can be used to carry or store desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto.
  • the processor 701 may be a central processing unit (CPU), or a digital processing module, etc., and the processor 701 is configured to read code in the memory for executing the test audio loop.
  • the method of extending is specifically: opening a preset playing thread, wherein the playing thread is configured to read a preset audio file from a buffer of the device, and play the preset audio file via a speaker of the device; Opening a preset recording thread, the recording thread is configured to record a preset audio file played by the speaker through a microphone of the device Determining an audio loop delay of the device according to the first time information of the playback thread playing the preset audio file and the second time information of the recording thread recording the preset audio file, the audio Loop delay refers to the time it takes for sound to be input from the microphone of the device to the output from the speaker of the device.
  • the processor 701 determines, according to the first time information that the preset audio file is played by the playing thread, and the second time information that the recording thread records the preset audio file, determining an audio loop of the device.
  • the time delay is specifically configured to: determine that the playing thread plays the first time information of the target data in the preset audio file; and determine that the recording thread records the second time information of the target data in the preset audio file; Determining an audio loop delay of the device according to a difference between the second time information and the first time information.
  • the preset audio file is a sine wave pulse code modulation PCM file
  • the sine wave PCM file is obtained by performing PCM processing on a sine wave of a first amplitude and a sine wave of a second amplitude
  • the target data of the preset audio file is a sample value corresponding to the first peak of the second amplitude sine wave.
  • the sampling value corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ by a first time length in the playing time, and the sampling value corresponding to the sine wave of the first amplitude is played.
  • the time is earlier than the playing time of the sample value corresponding to the sine wave of the second amplitude;
  • the processor 701 is specifically configured to: Recording, by the playing thread, time information for playing the preset audio file; starting time information for playing the preset audio file, the sine wave of the first amplitude, and a sine wave of the second amplitude according to the playing thread Determining, by the device, the time information of the sampling value corresponding to the sine wave of the second amplitude is started, and the sine of the second amplitude is started according to the device. Determining the time information of the sample value corresponding to the wave and the period of the second amplitude sine wave, determining that the playing thread plays the first
  • the preset audio file includes multi-frame audio data, each frame of audio data includes a plurality of PCM samples, each PCM sample corresponds to one PCM sample value; and the processor 701 determines that the recording thread records the pre-
  • the second time information of the target data in the audio file is specifically configured to: determine an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs; from the audio data frame to the time of reaching the recording thread Corresponding relationship, the audio data frame to which the PCM sample of the first peak is located corresponds to the time of reaching the recording thread, and the corresponding relationship between the audio data frame and the time of reaching the recording thread is according to the preset audio.
  • the audio data of each frame in the file is determined by the time of arrival of the recording thread; the sample number of the PCM sample corresponding to the first peak of the sine wave of the second amplitude, the length of the audio data frame, and the second amplitude
  • the sine wave is subjected to PCM sampling, and the PCM sample of the first peak of the sine wave of the second amplitude is determined to be recorded with respect to the belonging audio data frame.
  • the offset time of the thread time determining, according to the time when the belonging audio data frame arrives at the recording thread and the offset time, the recording thread to record the sample value corresponding to the first peak of the sine wave of the second amplitude Two time information.
  • the method is specifically configured to: calculate each PCM sample in the preset audio file.
  • the left gradient refers to the difference between the sampled value of a PCM sample and the sampled value of an adjacent left PCM sample
  • the right gradient refers to the sampled value of a PCM sample and the adjacent right PCM sample a difference between the sampled values
  • from the PCM samples of the preset audio file finding PCM samples whose left gradient and right gradient are both greater than zero, establishing a peak PCM sample set
  • the processor 701 determines an offset time of the PCM sample of the first peak in the sine wave of the second amplitude relative to the time at which the belonging audio data frame reaches the recording thread, and meets the following formula:
  • the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time;
  • the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave;
  • the FrameL represents the length of the audio data frame, the % represents the remainder, and
  • the Samplerate represents PCM sampling of the second amplitude sine wave by the device Frequency of.
  • device 700 can also include a communication interface for communicating with external devices.
  • connection medium between the processor 701 and the memory 702 is not limited in the embodiment of the present application.
  • the embodiment of the present application is connected by a bus between the processor 701 and the memory 702 in FIG. 7.
  • FIG. 7 is represented by a hollow double arrow line, but does not mean that there is only one bus or one type of bus, and other components are
  • the connection method is only for illustrative purposes and is not limited.
  • the bus can be divided into an address bus, a data bus, a control bus, and the like.
  • the device 700 may be a terminal as shown in FIG. 2, and the method of testing the audio loop delay as shown in FIG. 3 may be specifically performed.
  • the present application further provides an apparatus 800 for testing an audio loop delay, including:
  • the opening unit 801 is configured to enable a preset playing thread and a recording thread, where the playing thread is configured to read a preset audio file from a buffer of the terminal, and play the preset through a speaker of the terminal An audio file; the recording thread is configured to record a preset audio file played by the speaker through a microphone of the terminal;
  • a determining unit 802 configured to determine, according to the first time information that the playing thread plays the preset audio file, and the second time information that the recording thread records the preset audio file, determine an audio loop of the terminal
  • the audio loop delay refers to the time taken for the sound to be input from the microphone of the terminal to the speaker output from the terminal.
  • the determining unit 802 is specifically configured to: determine that the playing thread plays the first time information of the target data in the preset audio file; and determine that the recording thread records the target data in the preset audio file. Second time information; determining an audio loop delay of the terminal according to a difference between the second time information and the first time information.
  • the preset audio file is a sine wave pulse code modulation PCM file
  • the sine wave PCM file is obtained by performing PCM processing on a sine wave of a first amplitude and a sine wave of a second amplitude
  • the target data of the preset audio file is a sample value corresponding to the first peak of the second amplitude sine wave.
  • the sampling value corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ by a first time length in the playing time, and the sampling value corresponding to the sine wave of the first amplitude is played.
  • the determining unit 802 is configured to: when the playing thread plays the first time information of the target data in the preset audio file, to record time information that the playing thread starts playing the preset audio file; The playing thread starts playing the time information of the preset audio file, the sine wave of the first amplitude and the sampling time corresponding to the sine wave of the second amplitude are different in the playing time, and determining that the terminal starts playing Positive of the second amplitude Time information of the sampled value corresponding to the sine wave; determining, according to the time information of the sampling value corresponding to the sine wave of the second amplitude and the period of the second amplitude sine wave, determining the play thread playing station The first time information of the sample value corresponding to the first peak of the second amplitude sine wave.
  • the preset audio file includes multi-frame audio data, each frame of audio data includes a plurality of PCM samples, and each PCM sample corresponds to one PCM sample value;
  • the determining unit 802 is configured to: determine, by the recording thread, the second time information of the target data in the preset audio file, to determine that the PCM sample of the first peak of the second amplitude sine wave belongs to An audio data frame; in a correspondence between the audio data frame and the time of reaching the recording thread, searching for an audio data frame to which the PCM sample of the first peak belongs to correspond to a time of reaching the recording thread, the audio data frame and arrival Corresponding relationship of the recording thread time is determined according to the audio data of each frame in the preset audio file and the time of reaching the recording thread; the sample number of the PCM sample corresponding to the first peak of the sine wave according to the second amplitude a length of the audio data frame and a frequency of PCM sampling the sine wave of the second amplitude, determining that the PCM sample of the first peak of the second amplitude sine wave arrives at the recording thread with respect to the belonging audio data frame Time offset time; determining the recording thread recording station according to the time when the belonging audio data frame arrives at the recording thread
  • the determining unit 802 is specifically configured to: calculate each PCM sample in the preset audio file.
  • the left gradient refers to the difference between the sampled value of a PCM sample and the sampled value of an adjacent left PCM sample
  • the right gradient refers to the sampled value of a PCM sample and the adjacent right PCM sample a difference between the sampled values
  • from the PCM samples of the preset audio file finding PCM samples whose left gradient and right gradient are both greater than zero, establishing a peak PCM sample set
  • the determining unit 802 determines the offset time of the PCM sample of the first peak in the sine wave of the second amplitude relative to the time of the belonging audio data frame to the recording thread time, and meets the following formula:
  • the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time;
  • the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave;
  • the FrameL represents the length of the audio data frame, the % represents the remainder, and
  • the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
  • each functional module in each embodiment of the present application may be integrated into one processing. In the device, it can also be physically existed alone, or two or more modules can be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
  • Figure 7 or The device shown in Figure 2 can be a specific implementation of Figure 8.
  • One implementation of the opening unit 801 and the determining unit 802 shown in FIG. 8 is implemented by calling the computer storage instruction in the memory 702 by the processor 701 shown in FIG.
  • a computer readable storage medium comprising instructions for causing a computer to perform a method of testing an audio loop delay when it is run on a computer.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Abstract

A method and a device for testing the latency of an audio loop. The method comprises: a terminal starting a preset playing thread, the playing thread being used for reading a preset audio file from a buffer of the terminal, and playing the preset audio file by means of the loudspeaker of the terminal; the terminal starting a preset sound recording thread, the sound recording thread being used for recording, by means of the microphone of the terminal, the preset audio file played by the loudspeaker; the terminal determining the latency of the audio loop of the terminal, according to first time information concerning the playing thread playing the preset audio file and second time information concerning the sound recording thread recording the preset audio file, the latency of the audio loop referring to the time from a sound being inputted into the microphone of the terminal to the sound being outputted from the loudspeaker of the terminal. The method and device of the present application can test the latency of the audio loop.

Description

一种测试音频回路时延的方法及设备Method and device for testing audio loop delay
本申请要求在2016年12月30日提交中国专利局、申请号为201611264801.4、发明名称为“一种移动设备音频回路时延的测试方法和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese Patent Application filed on Dec. 30, 2016, the Chinese Patent Application No. 201611264801.4, entitled "A Test Method and Equipment for Delays of Audio Circuit Loops in Mobile Devices", the entire contents of which are hereby incorporated by reference. The citations are incorporated herein by reference.
技术领域Technical field
本申请涉及测试技术领域,尤其涉及一种测试音频回路时延的方法及设备。The present application relates to the field of testing technologies, and in particular, to a method and device for testing an audio loop delay.
背景技术Background technique
目前,无论是安卓或IOS操作系统的智能终端,其音频处理过程,主要由录音线程和播放线程两部分组成,如图1所示,录音线程的流程为:首先将声音从麦克风输入,然后经模拟数字转换器(Analog to Digital Converter,ADC)转换为音频数据,再经总线(Bus)和软硬件驱动将音频数据传输至系统音频服务单元,最后经第一音频传输单元将音频数据传输至用户应用程序的缓冲区。播放线程的流程为:第二音频传输单元从用户应用程序的缓冲区内读取音频数据,且将读取的音频数据传输至系统音频服务单元,系统音频服务单元再将经软硬件驱动和Bus将音频数据传输至数字模拟转换器(Digital to Analog Converter,DAC),DAC将音频数据转换为模拟数据,经扬声器播放该模拟数据。At present, the audio processing process of Android or IOS operating system is mainly composed of two parts: recording thread and playing thread. As shown in Figure 1, the flow of the recording thread is: first input the sound from the microphone, then The analog to digital converter (ADC) is converted into audio data, and then the audio data is transmitted to the system audio service unit via the bus and the hardware and software driver, and finally the audio data is transmitted to the user via the first audio transmission unit. The buffer of the application. The process of playing the thread is: the second audio transmission unit reads the audio data from the buffer of the user application, and transmits the read audio data to the system audio service unit, and the system audio service unit will be driven by the hardware and software and the Bus. The audio data is transmitted to a digital to analog converter (DAC), which converts the audio data into analog data, and the analog data is played through a speaker.
其中,音频回路时延是指声音从智能终端的麦克风输入,至扬声器输出的耗时。且随着智能终端的发展,越来越多的智能终端支持实时音效场景,比如k歌、DJ以及游戏等场景;由于在实时音效场景下,要求智能终端有较低的音频回路时延,因此如何测试智能终端的音频回路时延,是目前亟需解决的问题。Among them, the audio loop delay refers to the time taken for the sound to input from the microphone of the smart terminal to the output of the speaker. With the development of intelligent terminals, more and more intelligent terminals support real-time sound effects scenes, such as k songs, DJs, and games. Because in real-time sound effects scenarios, smart terminals are required to have lower audio loop delays. How to test the audio loop delay of the intelligent terminal is an urgent problem to be solved.
在现有技术中,常见的时延测试方法有两种,分别为软件日志和硬件测量;其中,软件日志为在关键操作的起始位置和结束位置打时间戳,通过对比时间戳进而获取关建操作耗时;而硬件测试一般应用于测试本地终端和远端终端之间的时延。通过上述分析可以看出,智能终端的音频回路时延的起点位置为将声音输入智能终端,终点位置为将声音输出智能终端。因为整个声音处理过程,涉及底层软件和硬件,无法在软件上记录时间戳,因此并不能用于测试智能终端内部的音频回路时延;而对于硬件测试其本质上是测试两台设备在一定空间分布下的音频时延,因此也无法测试智能终端内部的音频回路时延。In the prior art, there are two common delay test methods, namely software log and hardware measurement; wherein the software log is time stamped at the start position and the end position of the key operation, and the time stamp is obtained by comparing the time stamp. The build operation is time consuming; and the hardware test is generally applied to test the delay between the local terminal and the remote terminal. It can be seen from the above analysis that the starting position of the audio loop delay of the intelligent terminal is to input the sound into the intelligent terminal, and the end position is to output the sound to the intelligent terminal. Because the entire sound processing process, involving the underlying software and hardware, cannot record timestamps on the software, it cannot be used to test the audio loop delay inside the intelligent terminal; for hardware testing, it is essentially testing two devices in a certain space. The audio delay under distribution makes it impossible to test the audio loop delay inside the smart terminal.
发明内容Summary of the invention
本申请提供一种测试音频回路时延的方法及设备,以测试终端内部的音频回路时延。The present application provides a method and apparatus for testing an audio loop delay to test an audio loop delay inside a terminal.
第一方面,本申请提供一种测试音频回路时延的方法,包括:终端开启预设的播放线程,所述播放线程用于从所述终端的缓冲区中读取预设音频文件,且经所述终端的扬声器播放所述预设音频文件;所述终端开启预设的录音线程,所述录音线程用于通过所述终端的麦克风对所述扬声器播放的预设音频文件进行录音;所述终端根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述终端的音频回路时延,所述音频回路时延指声音从所述终端的麦克风输入, 至从所述终端的扬声器输出的耗时。In a first aspect, the present application provides a method for testing an audio loop delay, including: a terminal opening a preset play thread, where the play thread is configured to read a preset audio file from a buffer of the terminal, and The speaker of the terminal plays the preset audio file; the terminal starts a preset recording thread, and the recording thread is used to record a preset audio file played by the speaker through a microphone of the terminal; Determining an audio loop delay of the terminal according to the first time information that the playing thread plays the preset audio file and the second time information that the recording thread records the preset audio file, where the audio loop Time delay means that the sound is input from the microphone of the terminal. Time consuming to output from the speaker of the terminal.
可以看出,采用本申请的预设音频文件的方式,可确定终端内部音频回路的时延。It can be seen that the delay of the internal audio loop of the terminal can be determined by adopting the preset audio file of the present application.
结合第一方面,在第一种可能实现方式中,所述终端根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述终端的音频回路时延,包括:所述终端确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息;所述终端确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息;所述终端根据所述第二时间信息与所述第一时间信息的差值,确定所述终端的音频回路时延。With reference to the first aspect, in a first possible implementation manner, the terminal, according to the first time information of playing the preset audio file by the playing thread, and the second time of recording, by the recording thread, the preset audio file, Determining, by the terminal, determining, by the terminal, the first time information of the target data in the preset audio file; the terminal determining, by the recording thread, the pre-recording The second time information of the target data in the audio file is set; the terminal determines the audio loop delay of the terminal according to the difference between the second time information and the first time information.
可以看出,在本申请中,具体以预设音频文件的目标数据作为基准,计算音频回路时延,可使得计算音频回路时延的效率更高。It can be seen that in the present application, the audio loop delay is calculated by using the target data of the preset audio file as a reference, which can make the calculation of the audio loop delay more efficient.
结合第一种可能实现方式,在第二种可能实现方式中,所述预设音频文件为正弦波脉冲编码调制PCM文件,所述正弦波PCM文件为通过对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的;所述预设音频文件的目标数据为所述第二振幅正弦波中第一个波峰所对应的采样值。In conjunction with the first possible implementation, in a second possible implementation, the preset audio file is a sine wave pulse code modulation PCM file, and the sine wave PCM file is a sine wave and a second pass through the first amplitude The amplitude sine wave is obtained by PCM processing; the target data of the preset audio file is a sampling value corresponding to the first peak of the second amplitude sine wave.
在本申请中,采用第一振幅的正弦波和第二振幅的正弦波所对应的PCM文件作为目标数据,可方便计算录音线程录制所述目标数据的第一时间信息和播放线程播放所述目标数据的第二时间信息,从而提高计算音频回路时延的效率。In the present application, using the PCM file corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude as the target data, it is convenient to calculate the first time information of the recording thread recording the target data and the playing thread playing the target The second time information of the data, thereby improving the efficiency of calculating the audio loop delay.
结合第二种可能实现方式,在第三种可能实现方式中,所述第一振幅的正弦波和第二振幅的正弦波分别所对应的采样值在播放时间上相差第一时长,且所述第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间;In conjunction with the second possible implementation, in a third possible implementation, the sample values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ in play time by a first duration, and The playing time of the sampling value corresponding to the sine wave of the first amplitude is earlier than the playing time of the sampling value corresponding to the sine wave of the second amplitude;
所述终端确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息,包括:所述终端记录所述播放线程启动播放所述预设音频文件的时间信息;所述终端根据所述播放线程启动播放所述预设音频文件的时间信息、所述第一振幅的正弦波和第二振幅的正弦波所对应的采样值在播放时间上相差的第一时长,确定所述终端启动播放所述第二振幅的正弦波所对应的采样值的时间信息;所述终端根据所述终端启动播放所述第二振幅的正弦波所对应采样值的时间信息以及所述第二振幅正弦波的周期,确定所述播放线程播放所述第二振幅正弦波中第一个波峰所对应采样值的第一时间信息。Determining, by the terminal, that the playing thread plays the first time information of the target data in the preset audio file, including: the terminal recording time information that the playing thread starts playing the preset audio file; Determining, by the playing thread, the time information of playing the preset audio file, the sine wave of the first amplitude, and the sampling time corresponding to the sine wave of the second amplitude are different in the playing time, determining the terminal And starting to play time information of the sampling value corresponding to the sine wave of the second amplitude; the terminal starts to play the time information of the sampling value corresponding to the sine wave of the second amplitude according to the terminal, and the second amplitude sine a period of the wave, determining first time information of the sampling value corresponding to the first peak of the second amplitude sine wave played by the playing thread.
结合第二种可能实现方式或第三种可能实现方式,在第四种可能实现方式中,所述预设音频文件包括多帧音频数据,每帧音频数据包括多个PCM样本,每个PCM样本对应于一个PCM采样值;In combination with the second possible implementation manner or the third possible implementation manner, in a fourth possible implementation manner, the preset audio file includes multiple frames of audio data, and each frame of audio data includes multiple PCM samples, and each PCM sample Corresponding to a PCM sample value;
所述终端确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息,包括:所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;所述终端从音频数据帧与到达录音线程时间的对应关系中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间,所述音频数据帧与到达录音线程时间的对应关系为根据所述预设音频文件中每帧音频数据与到达录音线程的时间所确定的;所述终端根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号、音频数据帧的长度以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间的偏移时间;所述终端根据所归属音频数据帧到达录制线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。 Determining, by the terminal, that the recording thread records the second time information of the target data in the preset audio file, the terminal: determining, by the terminal, the audio to which the PCM sample of the first peak of the second amplitude sine wave belongs a data frame; the terminal searches for a time from the audio data frame to which the PCM sample of the first peak belongs to the time that the audio data frame belongs to the recording thread, and the audio data frame Corresponding relationship with the time of reaching the recording thread is determined according to the time of each frame of the audio data in the preset audio file and the time of reaching the recording thread; the terminal corresponding to the first peak of the sine wave of the second amplitude a sample number of the PCM sample, a length of the audio data frame, and a frequency of PCM sampling the sine wave of the second amplitude, determining a PCM sample of the first peak of the second amplitude sine wave relative to the assigned audio The offset time of the data frame to the recording thread time; the terminal according to the time when the belonging audio data frame arrives at the recording thread and the offset time, The fixed sine wave recorded recording the second thread in the first peak amplitude of the second time information corresponding to the sampling values.
结合第四种可能实现方式,在第五种可能实现方式中,所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧,包括:所述终端计算所述预设音频文件中每个PCM样本的左梯度和右梯度,所述左梯度指一PCM样本的采样值与相邻的左PCM样本的采样值的差值,所述右梯度指一PCM样本的采样值与相邻的右PCM样本的采样值的差值;所述终端从所述预设音频文件的PCM样本中,查找左梯度和右梯度均大于零的PCM样本,建立波峰PCM样本集合;所述终端从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样本的采样值,等于相邻的右波峰PCM样本的采样值;所述终端根据所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号以及预设的音频数据帧的长度,确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧。With reference to the fourth possible implementation manner, in a fifth possible implementation manner, the terminal determines, by the terminal, an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs, including: a left gradient and a right gradient of each PCM sample in the preset audio file, the left gradient being a difference between a sample value of a PCM sample and a sample value of an adjacent left PCM sample, the right gradient being a PCM a difference between the sampled value of the sample and the sampled value of the adjacent right PCM sample; the terminal searches for PCM samples whose left gradient and right gradient are both greater than zero from the PCM samples of the preset audio file, and establishes a peak PCM sample ???collecting, from the set of peak PCM samples, searching for a PCM sample of a first peak of a second amplitude sine wave, wherein the PCM sample of the first peak of the second amplitude sine wave corresponds to The sampled value is greater than the sampled value of the adjacent left peak PCM sample, equal to the sampled value of the adjacent right peak PCM sample; the terminal is based on the sample number of the PCM sample of the first peak of the second amplitude sine wave And preset The length of the audio data frame, the data frame is determined of audio PCM samples of said second sine amplitude of the first peak belongs.
结合第四种可能实现方式或第五种可能实现方式,在第六种可能实现方式中,所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:T=ij%FrameL*1/Samplerate;In conjunction with the fourth possible implementation or the fifth possible implementation, in a sixth possible implementation, the terminal determines a PCM sample of the first peak of the second amplitude sine wave relative to the assigned audio recording arrival time of the data frame offset time thread, in line with requirements of the following equation: T = i j% FrameL * 1 / samplerate;
其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述终端对所述第二振幅的正弦波进行PCM采样的频率。Wherein the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time; the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
第二方面,提供一种测试音频回路时延的设备,所述设备包括处理器和存储器;所述处理器,用于读取所述存储器中的代码,以用于执行:开启预设的播放线程,所述播放线程用于从所述设备的缓冲区中读取预设音频文件,且经所述设备的扬声器播放所述预设音频文件;开启预设的录音线程,所述录音线程用于通过所述设备的麦克风对所述扬声器播放的预设音频文件进行录音;根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述设备的音频回路时延,所述音频回路时延指声音从所述设备的麦克风输入,至从所述设备的扬声器输出的耗时。In a second aspect, an apparatus for testing an audio loop delay is provided, the apparatus comprising a processor and a memory; the processor, configured to read code in the memory for execution: enabling a preset playback a thread, the play thread is configured to read a preset audio file from a buffer of the device, and play the preset audio file via a speaker of the device; enable a preset recording thread, and the recording thread uses Recording a preset audio file played by the speaker through a microphone of the device; playing first time information of the preset audio file according to the playing thread, and recording, by the recording thread, the preset audio file The second time information determines an audio loop delay of the device, the audio loop delay being a time consuming time from the microphone input of the device to the output of the speaker of the device.
结合第二方面,在第一种可能实现方式中,所述处理器在根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述设备的音频回路时延时,具体用于:确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息;确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息;根据所述第二时间信息与所述第一时间信息的差值,确定所述设备的音频回路时延。With reference to the second aspect, in a first possible implementation, the processor is configured to play the first time information of the preset audio file according to the playing thread, and the recording thread records the preset audio file Determining, by the second time information, the delay time of the audio loop of the device, specifically, determining: determining, by the playing thread, the first time information of the target data in the preset audio file; determining that the recording thread records the preset Second time information of the target data in the audio file; determining an audio loop delay of the device according to a difference between the second time information and the first time information.
结合第一种可能实现方式,在第二种可能实现方式中,所述预设音频文件为正弦波脉冲编码调制PCM文件,所述正弦波PCM文件为通过对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的;所述预设音频文件的目标数据为所述第二振幅正弦波中第一个波峰所对应的采样值。In conjunction with the first possible implementation, in a second possible implementation, the preset audio file is a sine wave pulse code modulation PCM file, and the sine wave PCM file is a sine wave and a second pass through the first amplitude The amplitude sine wave is obtained by PCM processing; the target data of the preset audio file is a sampling value corresponding to the first peak of the second amplitude sine wave.
结合第二种可能实现方式,在第三种可能实现方式中,所述第一振幅的正弦波和第二振幅的正弦波分别所对应的采样值在播放时间上相差第一时长,且所述第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间;In conjunction with the second possible implementation, in a third possible implementation, the sample values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ in play time by a first duration, and The playing time of the sampling value corresponding to the sine wave of the first amplitude is earlier than the playing time of the sampling value corresponding to the sine wave of the second amplitude;
所述处理器在确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息时,具体用于:记录所述播放线程启动播放所述预设音频文件的时间信息;根据所述播放线程启动播放所述预设音频文件的时间信息、所述第一振幅的正弦波和第二振幅的正弦波 所对应的采样值在播放时间上相差的第一时长,确定所述设备启动播放所述第二振幅的正弦波所对应的采样值的时间信息;根据所述设备启动播放所述第二振幅的正弦波所对应采样值的时间信息以及所述第二振幅正弦波的周期,确定所述播放线程播放所述第二振幅正弦波中第一个波峰所对应采样值的第一时间信息。When determining, by the processor, the first time information of the target data in the preset audio file, the processor is specifically configured to: record time information that the playing thread starts playing the preset audio file; The playing thread starts time information for playing the preset audio file, the sine wave of the first amplitude, and the sine wave of the second amplitude a first time period in which the corresponding sampled value is different in the playing time, determining time information of the sampling value corresponding to the sine wave of the second amplitude that is started by the device; and starting to play the second amplitude according to the device The time information of the sampled value corresponding to the sine wave and the period of the second amplitude sine wave determine the first time information of the sampling value corresponding to the first peak of the second amplitude sine wave played by the playing thread.
结合第二种或第三种可能实现方式,在第四种可能实现方式中,所述预设音频文件包括多帧音频数据,每帧音频数据包括多个PCM样本,每个PCM样本对应于一个PCM采样值;In combination with the second or third possible implementation manner, in a fourth possible implementation manner, the preset audio file includes multi-frame audio data, each frame of audio data includes multiple PCM samples, and each PCM sample corresponds to one PCM sample value;
所述处理器在确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息时,具体用于:确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;从音频数据帧与到达录音线程时间的对应关系中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间,所述音频数据帧与到达录音线程时间的对应关系为根据所述预设音频文件中每帧音频数据与到达录音线程的时间所确定的;根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号、音频数据帧的长度以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间的偏移时间;根据所归属音频数据帧到达录制线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。When determining, by the processor, the second time information of the target data in the preset audio file, the processor is specifically configured to: determine that the PCM sample of the first peak of the second amplitude sine wave belongs to Audio data frame; from the correspondence between the audio data frame and the time of reaching the recording thread, searching for the audio data frame to which the PCM sample of the first peak belongs to correspond to the time of reaching the recording thread, the audio data frame and Corresponding relationship of the time of reaching the recording thread is determined according to the audio data of each frame in the preset audio file and the time of reaching the recording thread; the sample of the PCM sample corresponding to the first peak of the sine wave of the second amplitude a number, a length of the audio data frame, and a frequency of PCM sampling the sine wave of the second amplitude, determining that the PCM sample of the first peak of the second amplitude sine wave arrives at the recording with respect to the assigned audio data frame The offset time of the thread time; determining the recording thread recording station according to the time when the belonging audio data frame arrives at the recording thread and the offset time The second sine amplitude of the first peak of the second time information corresponding to the sampling values.
结合第四种可能实现方式,在第五种可能实现方式中,所述处理器在确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧时,具体用于:计算所述预设音频文件中每个PCM样本的左梯度和右梯度,所述左梯度指一PCM样本的采样值与相邻的左PCM样本的采样值的差值,所述右梯度指一PCM样本的采样值与相邻的右PCM样本的采样值的差值;从所述预设音频文件的PCM样本中,查找左梯度和右梯度均大于零的PCM样本,建立波峰PCM样本集合;从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样本的采样值,等于相邻的右波峰PCM样本的采样值;根据所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号以及预设的音频数据帧的长度,确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧。With reference to the fourth possible implementation manner, in a fifth possible implementation manner, when the determining, by the processor, the audio data frame to which the PCM sample of the first peak in the second amplitude sine wave belongs, Calculating a left gradient and a right gradient of each PCM sample in the preset audio file, the left gradient being a difference between a sample value of a PCM sample and a sample value of an adjacent left PCM sample, the right gradient finger The difference between the sampled value of a PCM sample and the sampled value of the adjacent right PCM sample; from the PCM samples of the preset audio file, find a PCM sample whose left gradient and right gradient are both greater than zero, and establish a peak PCM sample set Obtaining, from the set of peak PCM samples, a PCM sample of a first peak of a second amplitude sine wave, wherein a sample value corresponding to a PCM sample of the first peak of the second amplitude sine wave is greater than The sampled value of the adjacent left peak PCM sample is equal to the sample value of the adjacent right peak PCM sample; the sample number of the PCM sample of the first peak in the sine wave of the second amplitude and the preset audio data frame Length, indeed PCM samples in the sine wave amplitude of the second peak of the first audio frame belongs.
结合第四种或第五种可能实现方式,在第六种可能实现方式中,所述处理器在确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:In conjunction with the fourth or fifth possible implementation, in a sixth possible implementation, the processor determines a PCM sample of the first peak in the sine wave of the second amplitude relative to the assigned audio data The offset time of the frame arrival time of the recording thread meets the following formula:
T=ij%FrameL*1/Samplerate;T=i j %FrameL*1/Samplerate;
其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述设备对所述第二振幅的正弦波进行PCM采样的频率。Wherein the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time; the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents PCM sampling of the second amplitude sine wave by the device Frequency of.
第三方面,提供一种计算机可读存储介质,用于存储为执行本申请上述第一方面、第一方面的任意一种实现的功能所用的软件指令,其包含用于执行本发明上述第一方面、第一方面的任意一种实现的方法所设计的程序。In a third aspect, a computer readable storage medium is provided for storing software instructions for performing the functions of any of the above first aspect, the first aspect of the present application, comprising the first Aspect, the program designed by any of the methods of the first aspect.
由上可见,在本申请中,终端首先开启播放线程和录音线程,播放线程将播放预设音频文件,而录音线程将对播放线程播放的预设音频文件进行录音,且终端记录播放预设音频文件的第一时间信息和录制预设音频文件的第二时间信息;最后,终端根据第一时间信 息以及第二时间信息,即可确定终端内部的音频回路时延。As can be seen from the above, in the present application, the terminal first starts the playing thread and the recording thread, the playing thread will play the preset audio file, and the recording thread will record the preset audio file played by the playing thread, and the terminal records and plays the preset audio. The first time information of the file and the second time information of recording the preset audio file; finally, the terminal according to the first time letter The information and the second time information can determine the audio loop delay inside the terminal.
附图说明DRAWINGS
图1为本申请实施例提供的对音频数据的处理流程;FIG. 1 is a flowchart of processing audio data according to an embodiment of the present application;
图2为本申请实施例提供的终端的硬件结构示意图;FIG. 2 is a schematic structural diagram of hardware of a terminal according to an embodiment of the present disclosure;
图3为本申请实施例提供的测试音频回路时延的方法的流程示意图;FIG. 3 is a schematic flowchart diagram of a method for testing an audio loop delay according to an embodiment of the present disclosure;
图4为本申请实施例提供的测试音频回路时延的流程示意图;4 is a schematic flowchart of a test audio loop delay provided by an embodiment of the present application;
图5为本申请提供的PCM文件所对应正弦波的示意图;5 is a schematic diagram of a sine wave corresponding to a PCM file provided by the present application;
图6为本申请提供的测试音频回路时延的另一示意图;6 is another schematic diagram of a test audio loop delay provided by the present application;
图7为本申请提供的测试音频回路时延的设备的结构示意图;7 is a schematic structural diagram of an apparatus for testing an audio loop delay provided by the present application;
图8为本申请提供的测试音频回路时延的装置的结构示意图。FIG. 8 is a schematic structural diagram of an apparatus for testing an audio loop delay provided by the present application.
具体实施方式detailed description
为了便于理解,示例的给出了与本申请相关概念的说明以供参考,如下所示:For ease of understanding, the description of the concepts related to the present application is given by way of example, as follows:
终端:可以是可移动的终端(比如手机、便携式计算机和可穿戴设备等),也可以为不可移动的终端(比如,固定计算机以及电视等)。该终端至少包括麦克风和扬声器,用于对音频数据进行处理,主要将音频数据(比如用户声音)从麦克风输入进行录制,经过处理后,由扬声器输出。其音频处理过程主要由录音线程和播放线程组成。Terminal: It can be a mobile terminal (such as a mobile phone, a portable computer, and a wearable device), or it can be a non-mobile terminal (for example, a fixed computer, a television, etc.). The terminal includes at least a microphone and a speaker for processing audio data, and mainly recording audio data (such as user sound) from a microphone input, and processing, and outputting by the speaker. The audio processing process is mainly composed of a recording thread and a playing thread.
录音线程:可参照图1,其处理流程为,将模拟音频数据(比如用户声音)从麦克风输入,经过模拟数字转换器(Analog to Digital Converter,ADC)转换为数字音频数据,经总线Bus和软硬件驱动将数字音频数据传输至系统音频服务单元,再经第一音频传输单元将数字音频数据传输至缓冲区。Recording thread: Refer to Figure 1. The processing flow is to input analog audio data (such as user sound) from the microphone, convert it to digital audio data through analog to digital converter (ADC), via bus Bus and soft. The hardware driver transmits the digital audio data to the system audio service unit, and then transmits the digital audio data to the buffer through the first audio transmission unit.
播放线程:可参照图1,其处理流程为,第二音频传输单元从缓冲区内读取数字音频数据,且将读取的数字音频数据传输至系统音频服务单元,系统音频服务单元再经软硬件驱动和Bus将数字音频数据传输至数字模拟转换器(Digital to Analog Converter,DAC),而DAC将数字音频数据转换为模拟音频数据,经扬声器进行播放。Play thread: refer to FIG. 1 , the processing flow is: the second audio transmission unit reads the digital audio data from the buffer, and transmits the read digital audio data to the system audio service unit, and the system audio service unit is softened. The hardware driver and the Bus transfer the digital audio data to a Digital to Analog Converter (DAC), which converts the digital audio data into analog audio data for playback via the speaker.
需要说明的是,对于安卓操作系统的终端,在录制线程和播放线程中,其驱动可为ALSA,系统音频服务单元可为AudioFinger,第一音频传输单元可为Audio Record,第二音频传输单元可为Audio Track或Media palyer。且为了方便不同进程间的通信,在图1所示的示意图中,系统音频服务单元和第一音频传输单元中间还可包括一个Binder单元,系统音频服务单元和第二音频传输单元中间也还可包括一个Binder单元。It should be noted that, for the terminal of the Android operating system, in the recording thread and the playing thread, the driving may be ALSA, the system audio service unit may be AudioFinger, the first audio transmission unit may be Audio Record, and the second audio transmission unit may be For Audio Track or Media palyer. In order to facilitate communication between different processes, in the schematic diagram shown in FIG. 1, the system audio service unit and the first audio transmission unit may further include a Binder unit, and the system audio service unit and the second audio transmission unit may also be included. Includes a Binder unit.
音频回路时延:是指音频数据从终端的麦克风输入,至从终端的扬声器输出的时延;该时延主要由录音线程的录音时延和播放线程的播放时延组成。Audio loop delay: refers to the delay of audio data input from the terminal's microphone to the speaker output from the terminal; the delay is mainly composed of the recording delay of the recording thread and the playback delay of the playback thread.
正弦波脉冲编码调制(Pulse Code Modulation,PCM)文件:为对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的文件,所述PCM处理包括:对正弦波进行采样、量化和编码三个过程;所述PCM文件包括多帧音频数据,每帧音频数据包括多个PCM样本(比如,一帧音频数据可包括640个PCM样本),而每个PCM样本对应于正弦波的一个采样值。Sinusoidal Pulse Code Modulation (PCM) file: a file obtained by PCM processing a sine wave of a first amplitude and a sine wave of a second amplitude, the PCM processing comprising: sampling and quantizing a sine wave And encoding three processes; the PCM file includes multi-frame audio data, each frame of audio data includes a plurality of PCM samples (eg, one frame of audio data may include 640 PCM samples), and each PCM sample corresponds to a sine wave A sample value.
PCM样本:经过对第一振幅的正弦波或第二振幅的正弦波的一个采样点,经过量化和 编码后所获取的数据。PCM sample: a sample point passing through a sine wave of a first amplitude or a sine wave of a second amplitude, quantized and The data obtained after encoding.
下面结合附图,对本申请的技术方案进行介绍:The technical solution of the present application is introduced below with reference to the accompanying drawings:
本申请实施例中提供的测试音频回路时延的方法及设备,可应用于测试终端中音频回路时延,首先介绍一下本申请的应用场景:随着互联网的飞速发展,越来越多的终端支持实时音频场景,比如,K歌、DJ以及游戏等。在这些实时音频场景下,用户希望输入至终端的音频数据,能尽快的从终端中输出。基于此,本申请提供一种测试音频回路时延的方法及设备,以测试终端的音频回路时延。The method and device for testing the audio loop delay provided in the embodiment of the present application can be applied to the audio loop delay in the test terminal. First, the application scenario of the application is introduced. With the rapid development of the Internet, more and more terminals are provided. Support real-time audio scenes, such as K songs, DJs, and games. In these real-time audio scenarios, the audio data that the user wishes to input to the terminal can be output from the terminal as soon as possible. Based on this, the present application provides a method and apparatus for testing an audio loop delay to test an audio loop delay of a terminal.
在本申请的一种示例中,图2示出了终端200的一种硬件结构,如图2所示,可包括:处理器201、存储器202、显示设备203、输入设备204、音频电路205、麦克风206和扬声器207。In an example of the present application, FIG. 2 shows a hardware structure of the terminal 200, as shown in FIG. 2, which may include: a processor 201, a memory 202, a display device 203, an input device 204, an audio circuit 205, Microphone 206 and speaker 207.
其中,存储器202、显示设备203和输入设备204均与处理器201相连。存储器202,用于存储可执行程序,包括本申请提供的测试音频回路时延的方法的程序,存储器202包括内存和外存,内存可为随机存储器(RAM)、只读存储器(ROM)、以及高速缓冲存储器(CACHE)等。外存可为硬盘、光盘、USB盘、软盘或磁带机等。可执行程序通常被存储在外存上,处理器201会将可执行程序从外存加载到内存后再执行程序,比如,执行本申请提供的测试音频回路时延的方法的程序。The memory 202, the display device 203, and the input device 204 are all connected to the processor 201. The memory 202 is configured to store an executable program, including the program for testing the audio loop delay provided by the present application, the memory 202 includes a memory and an external memory, and the memory may be a random access memory (RAM), a read only memory (ROM), and Cache (CACHE), etc. The external storage can be a hard disk, a CD, a USB disk, a floppy disk or a tape drive. The executable program is usually stored on the external memory, and the processor 201 loads the executable program from the external memory into the memory before executing the program, for example, a program for performing the method for testing the audio loop delay provided by the present application.
下面结合图1对终端200的各个构成部件进行具体的介绍:The components of the terminal 200 will be specifically described below with reference to FIG. 1 :
处理器201是终端200的控制中心,利用各种接口和线路连接终端的各个部分,通过运行或执行存储在存储器202的程序(或者,称为“单元”),以及调用存储在存储器202内的数据,执行终端200的各种功能和数据处理,从而对终端200进行整体监控。The processor 201 is a control center of the terminal 200, which connects various parts of the terminal by various interfaces and lines, by running or executing a program (or "unit") stored in the memory 202, and calling the memory stored in the memory 202. The data, various functions and data processing of the terminal 200 are performed, thereby performing overall monitoring of the terminal 200.
可选的,处理器201可包括至少一个处理单元,该处理单元集成处理和无线通信功能;或者,处理器201也可包括应用处理器和调制解调器两个处理器,应用处理器主要处理操作系统、用户界面和应用程序等。调制解调器主要用于无线调通信。Optionally, the processor 201 may include at least one processing unit that integrates processing and wireless communication functions. Alternatively, the processor 201 may also include an application processor and a modem. The application processor mainly processes the operating system. User interface and applications, etc. Modems are primarily used for wireless communication.
存储器202,主要包括存储程序区和存储数据区。其中,存储程序区可存储终端的操作系统(比如,安卓操作系统、IOS操作系统等)、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)、以及本申请实施例所涉及的测试音频回路时延的方法的应用程序等。存储数据区可存储根据终端200的使用所创建的数据,包括本申请所涉及的测试音频回路时延的方法的相关设置信息或使用信息等。The memory 202 mainly includes a storage program area and a storage data area. The storage program area may store an operating system of the terminal (for example, an Android operating system, an IOS operating system, etc.), an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.), And an application program of the method for testing the audio loop delay involved in the embodiment of the present application. The storage data area may store data created according to the use of the terminal 200, including related setting information or usage information of the method of testing the audio loop delay involved in the present application.
显示设备203,用于显于用户输入的信息、提供给用户的信息以及终端200的各种菜单,包括本申请实施例中涉及的测试音频回路时延的方法的各种信息,比如参数配置信息以及测试结果显示信息等。The display device 203 is configured to display information input by the user, information provided to the user, and various menus of the terminal 200, including various information about a method for testing an audio loop delay involved in the embodiment of the present application, such as parameter configuration information. And test results display information and so on.
输入设备204,用于接收输入的数字、字符信息以及各种输入指令,比如,本申请提供的测试音频回路时延的方法的开始测试指令以及停止测试指令等。输入设备204也可括触控面板和/或其它类型输入设备。其中,触控面板也可称为触摸屏,可采集用户在其上或其附近的触摸操作(比如,用户使用手指、触笔等在其上或附近的触摸操作)。其它类型输入设备,可以包括但不限于物理键盘、功能键(比如音量控制按键和开关按键等)、鼠标、轨迹球和操作杆等中的一种或多种。The input device 204 is configured to receive the input digits, the character information, and various input commands, such as the start test command and the stop test command of the method for testing the audio loop delay provided by the present application. Input device 204 can also include a touch panel and/or other type of input device. The touch panel may also be referred to as a touch screen, and may collect a touch operation on or near the user (for example, a touch operation on or near the user using a finger, a stylus, or the like). Other types of input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons and switch buttons, etc.), a mouse, a trackball, and a joystick.
音频电路205,用于对经麦克风206进行声/电转换,对获得的模拟音频数据进行放大,转换为数字音频数据,进行PCM编码,编码后的数字音频数据发送至处理器201。或者, 将处理器201传送的数字音频数据进行PCM解码,将解码后的数字音频数据转换为模拟音频数据,然后进行功率放大,至扬声器207进行电/声转换,推动扬声器发声。The audio circuit 205 is configured to perform acoustic/electrical conversion on the microphone 206, amplify the obtained analog audio data, convert it into digital audio data, perform PCM encoding, and transmit the encoded digital audio data to the processor 201. Or, The digital audio data transmitted by the processor 201 is subjected to PCM decoding, the decoded digital audio data is converted into analog audio data, and then power amplification is performed, and the speaker 207 performs electrical/acoustic conversion to push the speaker to sound.
本领域技术人员可以理解,图2所示的终端200的内部结构并不构成对终端的限定,可以包括比图示更多或更少的部分,或者组合某些部件,或者不同的部件布置。例如,当终端200采用无线方式与外界通信时,还可包括射频(Rad io Frequency,RF)电路和连接的天线,无线保真(Wireless Fidelity,WIFI)模块和连接的天线等。此外,终端200还可包括传感器以及为其供电的电源等,在此不再一一列举It will be understood by those skilled in the art that the internal structure of the terminal 200 shown in FIG. 2 does not constitute a limitation to the terminal, and may include more or less parts than those illustrated, or combine some components, or different component arrangements. For example, when the terminal 200 communicates with the outside world in a wireless manner, it may further include a radio frequency (RF) circuit and a connected antenna, a wireless fidelity (WIFI) module, and a connected antenna. In addition, the terminal 200 may further include a sensor and a power source for supplying power thereto, etc., and are not enumerated here.
如图3所示,本申请提供一种测试音频回路时延的方法,该方法中所涉及的终端可具体为上述终端200,扬声器可具体为上述扬声器207,麦克风可具体为上述麦克风206。通过上述的音频回路时延的介绍可知,音频回路时延由录音线程的录音时延和播放线程的播放时延组成,该方法的主要原理为:预设音频文件,该预设音频文件预先置于终端中(比如置于上述图1中的缓冲区内,或其它存储区域,然后在执行测试时,再将预设音频文件加载至缓冲区内),启动播放线程,播放预设音频文件,记录播放预设文件的第一时间信息;同时,启动录音线程,录音线程将对播放线程播放的预设音频文件进行录音,获取录制音频文件的第二时间信息。然后,根据第一时间信息和第二时间信息,确定音频回路的时延,比如,将音频回路时延设置为第二时间信息与第一时间信息的差。As shown in FIG. 3, the present application provides a method for testing an audio loop delay. The terminal involved in the method may be specifically the terminal 200. The speaker may be specifically the speaker 207, and the microphone may be specifically the microphone 206. Through the introduction of the audio loop delay described above, the audio loop delay is composed of the recording delay of the recording thread and the playback delay of the playback thread. The main principle of the method is: preset audio file, the preset audio file is preset. In the terminal (such as placed in the buffer in Figure 1 above, or other storage area, and then load the preset audio file into the buffer when performing the test), start the playback thread, play the preset audio file, The first time information of playing the preset file is recorded; at the same time, the recording thread is started, and the recording thread records the preset audio file played by the playing thread to obtain the second time information of the recorded audio file. Then, based on the first time information and the second time information, the delay of the audio loop is determined, for example, the audio loop delay is set as the difference between the second time information and the first time information.
具体如下:details as follows:
步骤S31:终端开启预设的播放线程。Step S31: The terminal starts a preset playing thread.
具体的,如图4所示,播放线程的处理过程为:第二音频传输单元从缓冲区内读取预设音频文件,且将读取的预设音频文件传输至系统音频服务单元,系统音频服务单元再经软硬件驱动和Bus将预设音频文件传输至DAC,而DAC将预设音频文件转换为模拟文件,进行电/声转换,经扬声器进行播放。Specifically, as shown in FIG. 4, the processing process of the playing thread is: the second audio transmission unit reads the preset audio file from the buffer, and transmits the read preset audio file to the system audio service unit, the system audio. The service unit then transmits the preset audio file to the DAC via the hardware and software driver and the Bus, and the DAC converts the preset audio file into an analog file for electrical/audio conversion and plays through the speaker.
步骤S32:终端开启预设的录音线程。Step S32: The terminal starts a preset recording thread.
具体的,仍可参照图4,录音线程的处理过程为:麦克风中将输入扬声器播放的声音,经声/电转换,此时可获得模拟文件,经ADC变换可将模拟文件转换为数字文件,此时的数字文件即为预设音频文件;再经驱动和系统音频服务单元将预设音频文件,传输至第一音频传输单元,而第一音频传输单元将预设音频文件写入至缓冲区。Specifically, still referring to FIG. 4, the processing process of the recording thread is: the sound played by the input speaker in the microphone is converted by sound/electricity, and the analog file can be obtained at this time, and the analog file can be converted into a digital file by ADC conversion. The digital file at this time is a preset audio file; the preset audio file is transmitted to the first audio transmission unit via the driving and system audio service unit, and the first audio transmission unit writes the preset audio file to the buffer. .
步骤S33:终端根据播放线程播放所述预设音频文件的第一时间信息以及录音线程录制所述音频文件的第二时间信息,确定终端的音频回路时延。Step S33: The terminal determines the audio loop delay of the terminal according to the first time information of the preset audio file played by the playing thread and the second time information of the audio file recorded by the recording thread.
在本申请中,可在预设音频文件中确定一目标数据,该目标数据可作为计算音频回路时延的基准。然后,确定播放线程开始播放该目标数据的第一时间信息,以及录制线程录制该目标数据的第二时间信息,最后,将第二时间信息与第一时间信息的差,作为所述终端的音频回路时延;比如,第二时间信息为10点59分50秒35毫秒,而第一时间信息为10点59分50秒40毫秒,那么,终端的音频回路时延为5毫秒。In the present application, a target data can be determined in a preset audio file, which can be used as a reference for calculating an audio loop delay. Then, determining a first time information that the playing thread starts playing the target data, and a second time information that the recording thread records the target data, and finally, a difference between the second time information and the first time information as the audio of the terminal Loop delay; for example, the second time information is 10:59:50,35 milliseconds, and the first time information is 10:59:50,40 milliseconds, then the audio loop delay of the terminal is 5 milliseconds.
应当指出,上述第一时间信息和第二时间信息仅仅是为了区分不同的时间信息,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。It should be noted that the first time information and the second time information described above are merely for distinguishing different time information, and are not to be understood as indicating or implying relative importance, nor as indicating or suggesting order.
还应当指出,在本申请实施例中,所述步骤S31—步骤S33并不限定终端执行本申请步骤的前后顺序,可按照步骤S31、步骤S32和步骤S33的顺序执行本申请提供的方法,也可按照步骤S32、步骤S31、步骤S33的顺序执行本申请的方法,均在本申请的保护范围内。而为了避免漏录,可先执行步骤S32开启录音线程,再执行步骤S31执行开启播放 线程。It should be noted that, in the embodiment of the present application, the step S31 to the step S33 do not limit the sequence before and after the terminal performs the steps of the present application, and the method provided by the present application may be performed in the order of step S31, step S32, and step S33. The method of the present application can be performed in the order of step S32, step S31, and step S33, all within the scope of protection of the present application. In order to avoid the missed recording, the recording thread may be first executed in step S32, and then the step S31 is executed to perform the playback. Thread.
由上可见,在本申请中,终端首先开启播放线程和录音线程,播放线程将播放预设音频文件,而录音线程将对播放线程播放的预设音频文件进行录音,且终端记录播放预设音频文件的第一时间信息和录制预设音频文件的第二时间信息;最后,终端根据第一时间信息以及第二时间信息,即可确定终端内部的音频回路时延。As can be seen from the above, in the present application, the terminal first starts the playing thread and the recording thread, the playing thread will play the preset audio file, and the recording thread will record the preset audio file played by the playing thread, and the terminal records and plays the preset audio. The first time information of the file and the second time information of the preset audio file are recorded; finally, the terminal determines the audio loop delay inside the terminal according to the first time information and the second time information.
在本申请的另一可行实施例中,所述预设音频文件可为正弦波PCM文件;其中,所述正弦波PCM文件为对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的文件,所述PCM处理包括对正弦波进行采样、量化和编码三个过程。In another possible embodiment of the present application, the preset audio file may be a sine wave PCM file; wherein the sine wave PCM file performs PCM processing on a sine wave of a first amplitude and a sine wave of a second amplitude The obtained file, the PCM processing includes three processes of sampling, quantizing, and encoding a sine wave.
在本申请实施例中,如图5所示,比如,第一振幅的正弦波的振幅可为A,第二振幅的正弦波的振幅可为2A;且第一振幅的正弦波和第二振幅的正弦波的频率可相同,也可不同,比如,两者的频率可均为440HZ。In the embodiment of the present application, as shown in FIG. 5, for example, the amplitude of the sine wave of the first amplitude may be A, the amplitude of the sine wave of the second amplitude may be 2A; and the sine wave and the second amplitude of the first amplitude The frequency of the sine wave may be the same or different, for example, the frequency of both may be 440HZ.
在本申请中,可具体将上述正弦波PCM文件中第二振幅的正弦波的第一个波峰所对应的采样值作为目标数据,计算音频回路时延,过程具体如下:In the present application, the sampling value corresponding to the first peak of the second amplitude sine wave in the sine wave PCM file may be specifically used as the target data to calculate the audio loop delay, and the process is as follows:
第一,终端确定所述播放线程播放所述所述第二振幅的正弦波中第一个波峰所对应采样值的第一时间信息。First, the terminal determines that the playing thread plays the first time information of the sample value corresponding to the first peak of the sine wave of the second amplitude.
在本申请实施例中,更具体的,第一振幅的正弦波与第二振幅的正弦波分别对应的采样值在播放时间上可相差第一时长Δt,且第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间。比如,首先播放第一振幅的正弦波的采样值,且在播放第一振幅的正弦波5S后,再播放第二振幅的正弦波所对应的采样值。In the embodiment of the present application, more specifically, the sampling values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively may be different in the playing time by the first time length Δt, and the sine wave corresponding to the first amplitude corresponds to The playing time of the sampled value is earlier than the playing time of the sampled value corresponding to the sine wave of the second amplitude. For example, the sample value of the sine wave of the first amplitude is played first, and after the sine wave 5S of the first amplitude is played, the sample value corresponding to the sine wave of the second amplitude is played.
在本申请中,仍可参见图5,计算过程如下:记录播放线程启动播放预设音频文件的时间信息(比如在时间T1,启动播放预设音频文件),然后根据时间T1、第一振幅的正弦波与第二振幅的正弦波在播放时间上相差的第一时长(比如为Δt),计算启动播放第二振幅的正弦波所对应采集值的时间信息(比如为T1+Δt);然后,根据T1+Δt、以及第二振幅的正弦波的周期T,确定所述播放线程播放第二振幅的正弦波中第一个波峰所对应采样值的第一时间信息;通过图5可以看出,从开始播放第二振幅正弦波开始,至播放至第二振幅的正弦波的第一个波峰中间经过1/4T,所述T为第二振幅正弦波的周期,因此,最后,可确定播放线程播放第二振幅正弦波的第一个波峰所对应采样值的第一时间信息为T1+Δt+1/4T。In the present application, still referring to FIG. 5, the calculation process is as follows: recording the time information that the playing thread starts playing the preset audio file (for example, starting the playing of the preset audio file at time T1), and then according to the time T1, the first amplitude The first time duration (for example, Δt) of the sine wave and the sine wave of the second amplitude are different in the playing time, and time information (for example, T1+Δt) corresponding to the acquired value of the sine wave that starts playing the second amplitude is calculated; Determining, according to T1+Δt, and a period T of the sine wave of the second amplitude, the first time information of the sampling value corresponding to the first peak of the sine wave of the second amplitude played by the playing thread; as can be seen from FIG. Starting from the start of playing the second amplitude sine wave, the first peak of the sine wave played to the second amplitude passes through 1/4T, and the T is the period of the second amplitude sine wave, so finally, the playing thread can be determined. The first time information for playing the sample value corresponding to the first peak of the second amplitude sine wave is T1 + Δt + 1/4T.
在实际应用中,针对回路时延精确度要求较低的情况下,也可将T1+Δt直接作为播放第二振幅正弦波的第一个波峰所对应采样值的第一时间信息,此种方式,也在本申请的保护范围内。In practical applications, for the case where the loop delay accuracy requirement is low, T1+Δt can also be directly used as the first time information of the sample value corresponding to the first peak of the second amplitude sine wave. Also within the scope of protection of this application.
第二,终端确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息,可参照图6所示。Second, the terminal determines that the recording thread records the second time information of the sample value corresponding to the first peak of the sine wave of the second amplitude, as shown in FIG. 6.
步骤S61:确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;Step S61: determining an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs;
具体的,所述预设音频文件可包括多帧音频数据,在本申请中,终端会记录预设音频文件中每帧音频数据到达录音线程的时间,形成帧索引与时间的对应关系MAP,比如MAP={(第1帧音频数据,Time1),(第2帧音频数据,Time2),(第3帧音频数据,Time3)……}。其中,Timel、Time2.....TimeN为相对应的每帧音频数据至达录音线程的 时间。Specifically, the preset audio file may include multi-frame audio data. In the present application, the terminal records the time when the audio data of each frame in the preset audio file reaches the recording thread, and forms a correspondence relationship between the frame index and the time, such as MAP. MAP={(1st frame audio data, Time1), (2nd frame audio data, Time2), (3rd frame audio data, Time3)......}. Among them, Timel, Time2.....TimeN is the corresponding audio data of each frame up to the recording thread. time.
而每帧音频数据可包括多个PCM样本(比如,通常一帧音频数据包括640个PCM样本),每个PCM样本对应于一PCM采样值。对于每帧音频数据内的每个PCM样本,可求每个PCM样本的左梯度GradientL[n]和右梯度GradientR[n]。And each frame of audio data may include a plurality of PCM samples (eg, typically one frame of audio data includes 640 PCM samples), each PCM sample corresponding to a PCM sample value. For each PCM sample within each frame of audio data, the left gradient GradientL[n] and the right gradient GradientR[n] for each PCM sample can be found.
左梯度GradientL[n]=Sample[n]-Sample[n-1];Left gradient GradientL[n]=Sample[n]-Sample[n-1];
右梯度GradientR[n]=Sample[n]-Sample[n+1];Right gradient GradientR[n]=Sample[n]-Sample[n+1];
其中,Sample[n]代表当前PCM样本,Sample[n-1]代表在一帧音频数据中,当前PCM样本中左相邻的PCM样本,Sample[n+1]代表在一帧音频数据中,当前PCM样本右相邻的PCM样本。Among them, Sample[n] represents the current PCM sample, Sample[n-1] represents the left adjacent PCM sample in the current PCM sample in one frame of audio data, and Sample[n+1] represents one frame of audio data. The PCM sample immediately adjacent to the current PCM sample.
统计每个音频数据内左梯度和右梯度均大于0的PCM样本,建立波峰PCM样本集合;Counting PCM samples whose left gradient and right gradient are greater than 0 in each audio data, and establishing a peak PCM sample set;
其中,如果一个PCM样本的左梯度和右梯度都大于0,说明该PCM样本为代表正弦波的波峰所对应的采集值;Wherein, if both the left gradient and the right gradient of one PCM sample are greater than 0, it indicates that the PCM sample is an acquisition value corresponding to a peak representing a sine wave;
而波峰PCM样本集合包括波峰集索引集合SI和波峰值集合SV;其中,波峰集索引集合SI中代表每个波峰样本的PCM编号,波峰值集合SV代表波峰对应的采样值的大小;The peak PCM sample set includes a peak set index set S I and a wave peak set S V ; wherein the peak set index set S I represents the PCM number of each peak sample, and the wave peak set S V represents the size of the sample value corresponding to the peak ;
SI={i1,i2,…im};S I ={i 1 ,i 2 ,...i m };
SV={v1,v2,…im};S V ={v 1 ,v 2 ,...i m };
从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,如图5所示,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样本的采样值,等于相邻的右波峰PCM样本的采样值;From the set of peak PCM samples, searching for a PCM sample of the first peak of the second amplitude sine wave, wherein, as shown in FIG. 5, the PCM sample of the first peak of the second amplitude sine wave The corresponding sample value is greater than the sample value of the adjacent left peak PCM sample, and is equal to the sample value of the adjacent right peak PCM sample;
在本申请中,具体的实施方式可为:迭代波峰值集合SV,求波峰梯度G[j]。In the present application, a specific implementation may be: an iterative wave peak set S V , and a peak gradient G[j].
G[j]=V[j]-V[j-1];G[j]=V[j]-V[j-1];
其中,V[j]代表当前波峰所对应的采样值,V[j-1]代表当前波峰相邻的左波峰所对应的采样值;通过图5所示看出,只有第二振幅的正弦波的第一个波峰,其左相邻的波峰为A,其2A与A的差值才会大于0。Where V[j] represents the sample value corresponding to the current peak, and V[j-1] represents the sample value corresponding to the left peak adjacent to the current peak; as seen in FIG. 5, only the second amplitude sine wave The first peak, whose left adjacent peak is A, will have a difference between 2A and A greater than zero.
在确定出第二振幅的正弦波的第一个波峰所对应的峰值后,在波峰集索引集合SI={i1,i2,…im}集合中,查找该波峰对应的PCM样本编号IjAfter determining the peak corresponding to the first peak of the second amplitude sine wave, in the set of peak set index S I = {i 1 , i 2 , ... i m }, find the PCM sample number corresponding to the peak I j ;
最后,根据第二振幅的正弦波中第一个波峰的PCM样本编号Ij以及每个音频数据帧的长度,确定第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;Finally, based on the PCM sample number I j of the first peak of the second amplitude sine wave and the length of each audio data frame, the audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs is determined. ;
比如,在本申请中,将第二振幅正弦波的第一个波峰的PCM样本编号Ij与每帧音频数据的长度FrameL作比,可确定Ij所归属的音频数据帧;比如Ij为10014;而FrameL为1000,那么可确定Ij/FrameL=10,可确定Ij位于第11个音频数据帧内。FrameL可具体为每帧包括PCM样本的数量。For example, in the present application, the PCM sample number I j of the first peak of the second amplitude sine wave is compared with the length FrameL of each frame of audio data, and the audio data frame to which I j belongs can be determined; for example, I j is 10014; and FrameL is 1000, then I j /FrameL=10 can be determined, and it can be determined that I j is located in the eleventh audio data frame. FrameL may specifically include the number of PCM samples per frame.
步骤S62:从音频数据帧与到达录音线程时间的对应关系MAP中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间;Step S62: Searching, from the correspondence relationship MAP between the audio data frame and the time of the recording thread, the time at which the audio data frame to which the PCM sample of the first peak belongs belongs to the recording thread;
比如,上述Ij位于第11个音频数据帧,可具体在上述MAP={(第1帧音频数据,Time1),(第2帧音频数据,Time2),(第3帧音频数据,Time3)……}中查找第11帧音频数据到达录音线程的时间Time11。For example, the above I j is located in the eleventh audio data frame, and may be specifically in the above MAP={(first frame audio data, Time1), (second frame audio data, Time2), (third frame audio data, Time3)... ...} finds the time 11 of the 11th frame of audio data arriving at the recording thread.
步骤S63:根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号Ij、音频数据帧的长度FrameL以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间 的偏移时间;Step S63: the sample number of PCM samples in the first peak amplitude of the second sine wave corresponds according to I j, the audio data frame length FrameL PCM samples and the frequency of the second sinusoidal amplitude, determined An offset time of the PCM sample of the first peak of the second amplitude sine wave relative to the assigned audio data frame to the recording thread time;
其中,所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:The terminal determines the offset time of the PCM sample of the first peak of the second amplitude sine wave relative to the time at which the assigned audio data frame reaches the recording thread, which meets the following formula:
T=ij%FrameL*1/Samplerate;T=i j %FrameL*1/Samplerate;
其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述Ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述终端对所述第二振幅的正弦波进行PCM采样的频率。Wherein said T represents an offset time of a PCM sample of a first peak of said second amplitude sine wave relative to a time of arrival of said belonging audio data frame; said Ij representing said second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
具体的,仍沿用上述举例,Ij为10014,而FrameL为1000,那么Ij与FrameL求余可得到为14,可见,Ij在所归属的数据帧内为第14个PCM样本,那么,14*1/Samplerate即为Ij在所归属的音频数据帧内的偏移时间,Samplerate代表进行PCM采样的频率,而1/Samplerate代表进行PCM采样的周期,即每间隔多长时间采集一个PCM样本;而14*1/Samplerate即为在当前音频数据帧内采集第14个PCM样本的时间信息。Specifically, the above example is still used, I j is 10014, and FrameL is 1000, then I j and FrameL can be obtained as 14, and it can be seen that I j is the 14th PCM sample in the belonging data frame, then, 14*1/Samplerate is the offset time of I j in the audio data frame to which it belongs, Samplerate represents the frequency of PCM sampling, and 1/Samplerate represents the period of PCM sampling, ie, how long to collect a PCM per interval Sample; and 14*1/Samplerate is the time information for collecting the 14th PCM sample in the current audio data frame.
步骤S64:根据所归属音频数据帧到达录音线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。Step S64: Determine, according to the time when the belonging audio data frame arrives at the recording thread and the offset time, the recording time to record the second time information of the sample value corresponding to the first peak in the sine wave of the second amplitude.
在本申请中,可具体将第二振幅正弦波的第一个波峰所归属音频数据帧到达录音线程的时间和计算得到的编移时间作和,作为第二振幅正弦波中的第一个波峰到达录音线程的第二时间信息。In the present application, the time when the audio data frame to which the first peak of the second amplitude sine wave belongs to the recording thread and the calculated programming time may be specifically summed as the first peak in the second amplitude sine wave. The second time information that reaches the recording thread.
而最后,整个音频回路的时延Tloop符合下述公式:Finally, the delay Tloop of the entire audio loop conforms to the following formula:
Tloop=TimeFrameIndex+Ij%FrameL*1/Samplerate-(T1+Δt+1/4T);Tloop=TimeFrameIndex+Ij%FrameL*1/Samplerate-(T1+Δt+1/4T);
其中,TimeFrameIndex+Ij%FrameL*1/Samplerate代表录音线程开始录制第二振幅正弦波中第一个波峰的第二时间信息,其中,TimeFrameIndex代表第二振幅的正弦波中第一个波峰所归属的音频数据帧到达录音线程的时间,Ij%FrameL*1/Samplerate代表第二振幅振幅正弦波的第一个波峰在所归属的数据在帧内的偏移时间;(T1+Δt+1/4T)代表播放线程开始播放第二振幅正弦波中第一个波峰的第一时间,T1为开始播放第一振幅正弦波的时间,而Δt代表第二振幅正弦波与第一振幅正弦波在播放时间上相差的时间,1/4T代表从开始播放第二振幅正弦波到播放到波峰的时间。Wherein, TimeFrameIndex+Ij%FrameL*1/Samplerate represents the second time information of the recording thread starting to record the first peak of the second amplitude sine wave, wherein TimeFrameIndex represents the first peak of the second amplitude sine wave belongs to When the audio data frame reaches the recording thread, Ij%FrameL*1/Samplerate represents the offset time of the first peak of the second amplitude amplitude sine wave within the frame of the belonging data; (T1+Δt+1/4T) Representing the first time when the playing thread starts playing the first peak of the second amplitude sine wave, T1 is the time to start playing the first amplitude sine wave, and Δt represents the second amplitude sine wave and the first amplitude sine wave in the playing time The time difference, 1/4T represents the time from the start of playing the second amplitude sine wave to the play to the peak.
在本申请的另一可行实施例中,如图7所示,提供一种测试音频回路时延的设备700,包括处理器701和存储器702;In another possible embodiment of the present application, as shown in FIG. 7, an apparatus 700 for testing an audio loop delay is provided, including a processor 701 and a memory 702;
其中,存储器702,用于存储上述测试音频回路时延的方法的程序指令;存储器702可以是非易失性存储器,比如硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)等,还可以是易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM)。存储器是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。The memory 702 is used to store the program instructions of the method for testing the audio loop delay. The memory 702 may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD). It can also be a volatile memory such as a random-access memory (RAM). A memory is any other medium that can be used to carry or store desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto.
处理器701,可以是一个中央处理模块(central processing unit,CPU),或者为数字处理模块等等;处理器701,用于读取所述存储器中的代码,以用于执行上述测试音频回路时延的方法,具体为:开启预设的播放线程,所述播放线程用于从所述设备的缓冲区中读取预设音频文件,且经所述设备的扬声器播放所述预设音频文件;开启预设的录音线程,所述录音线程用于通过所述设备的麦克风对所述扬声器播放的预设音频文件进行录 音;根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述设备的音频回路时延,所述音频回路时延指声音从所述设备的麦克风输入,至从所述设备的扬声器输出的耗时。The processor 701 may be a central processing unit (CPU), or a digital processing module, etc., and the processor 701 is configured to read code in the memory for executing the test audio loop. The method of extending is specifically: opening a preset playing thread, wherein the playing thread is configured to read a preset audio file from a buffer of the device, and play the preset audio file via a speaker of the device; Opening a preset recording thread, the recording thread is configured to record a preset audio file played by the speaker through a microphone of the device Determining an audio loop delay of the device according to the first time information of the playback thread playing the preset audio file and the second time information of the recording thread recording the preset audio file, the audio Loop delay refers to the time it takes for sound to be input from the microphone of the device to the output from the speaker of the device.
可选的,处理器701在根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述设备的音频回路时延时,具体用于:确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息;确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息;根据所述第二时间信息与所述第一时间信息的差值,确定所述设备的音频回路时延。Optionally, the processor 701 determines, according to the first time information that the preset audio file is played by the playing thread, and the second time information that the recording thread records the preset audio file, determining an audio loop of the device. The time delay is specifically configured to: determine that the playing thread plays the first time information of the target data in the preset audio file; and determine that the recording thread records the second time information of the target data in the preset audio file; Determining an audio loop delay of the device according to a difference between the second time information and the first time information.
可选的,所述预设音频文件为正弦波脉冲编码调制PCM文件,所述正弦波PCM文件为通过对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的;Optionally, the preset audio file is a sine wave pulse code modulation PCM file, and the sine wave PCM file is obtained by performing PCM processing on a sine wave of a first amplitude and a sine wave of a second amplitude;
所述预设音频文件的目标数据为所述第二振幅正弦波中第一个波峰所对应的采样值。The target data of the preset audio file is a sample value corresponding to the first peak of the second amplitude sine wave.
可选的,所述第一振幅的正弦波和第二振幅的正弦波分别所对应的采样值在播放时间上相差第一时长,且所述第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间;处理器701在确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息时,具体用于:记录所述播放线程启动播放所述预设音频文件的时间信息;根据所述播放线程启动播放所述预设音频文件的时间信息、所述第一振幅的正弦波和第二振幅的正弦波所对应的采样值在播放时间上相差的第一时长,确定所述设备启动播放所述第二振幅的正弦波所对应的采样值的时间信息;根据所述设备启动播放所述第二振幅的正弦波所对应采样值的时间信息以及所述第二振幅正弦波的周期,确定所述播放线程播放所述第二振幅正弦波中第一个波峰所对应采样值的第一时间信息。Optionally, the sampling value corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ by a first time length in the playing time, and the sampling value corresponding to the sine wave of the first amplitude is played. The time is earlier than the playing time of the sample value corresponding to the sine wave of the second amplitude; when determining, by the processor 701, the first time information of the target data in the preset audio file, the processor 701 is specifically configured to: Recording, by the playing thread, time information for playing the preset audio file; starting time information for playing the preset audio file, the sine wave of the first amplitude, and a sine wave of the second amplitude according to the playing thread Determining, by the device, the time information of the sampling value corresponding to the sine wave of the second amplitude is started, and the sine of the second amplitude is started according to the device. Determining the time information of the sample value corresponding to the wave and the period of the second amplitude sine wave, determining that the playing thread plays the first peak of the second amplitude sine wave A first time information of the sampled values.
可选的,所述预设音频文件包括多帧音频数据,每帧音频数据包括多个PCM样本,每个PCM样本对应于一个PCM采样值;处理器701在确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息时,具体用于:确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;从音频数据帧与到达录音线程时间的对应关系中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间,所述音频数据帧与到达录音线程时间的对应关系为根据所述预设音频文件中每帧音频数据与到达录音线程的时间所确定的;根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号、音频数据帧的长度以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间的偏移时间;根据所归属音频数据帧到达录制线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。Optionally, the preset audio file includes multi-frame audio data, each frame of audio data includes a plurality of PCM samples, each PCM sample corresponds to one PCM sample value; and the processor 701 determines that the recording thread records the pre- The second time information of the target data in the audio file is specifically configured to: determine an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs; from the audio data frame to the time of reaching the recording thread Corresponding relationship, the audio data frame to which the PCM sample of the first peak is located corresponds to the time of reaching the recording thread, and the corresponding relationship between the audio data frame and the time of reaching the recording thread is according to the preset audio. The audio data of each frame in the file is determined by the time of arrival of the recording thread; the sample number of the PCM sample corresponding to the first peak of the sine wave of the second amplitude, the length of the audio data frame, and the second amplitude The sine wave is subjected to PCM sampling, and the PCM sample of the first peak of the sine wave of the second amplitude is determined to be recorded with respect to the belonging audio data frame. The offset time of the thread time; determining, according to the time when the belonging audio data frame arrives at the recording thread and the offset time, the recording thread to record the sample value corresponding to the first peak of the sine wave of the second amplitude Two time information.
可选的,处理器701在确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧时,具体用于:计算所述预设音频文件中每个PCM样本的左梯度和右梯度,所述左梯度指一PCM样本的采样值与相邻的左PCM样本的采样值的差值,所述右梯度指一PCM样本的采样值与相邻的右PCM样本的采样值的差值;从所述预设音频文件的PCM样本中,查找左梯度和右梯度均大于零的PCM样本,建立波峰PCM样本集合;从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样本的采样值,等于相邻的右波峰PCM样本的采样值;根据所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号以及预设的音频数据帧的长度,确定所述第二振幅的正弦波中第一个波峰的PCM样本 所归属的音频数据帧。Optionally, when determining, by the processor 701, the audio data frame to which the PCM sample of the first peak in the sine wave of the second amplitude belongs, the method is specifically configured to: calculate each PCM sample in the preset audio file. Left gradient and right gradient, the left gradient refers to the difference between the sampled value of a PCM sample and the sampled value of an adjacent left PCM sample, the right gradient refers to the sampled value of a PCM sample and the adjacent right PCM sample a difference between the sampled values; from the PCM samples of the preset audio file, finding PCM samples whose left gradient and right gradient are both greater than zero, establishing a peak PCM sample set; and searching for the second amplitude from the peak PCM sample set a PCM sample of a first peak in the sine wave, wherein a sample value corresponding to the PCM sample of the first peak of the second amplitude sine wave is greater than a sample value of the adjacent left peak PCM sample, equal to the adjacent a sample value of the right peak PCM sample; determining a sine wave of the second amplitude according to a sample number of the PCM sample of the first peak of the second amplitude sine wave and a length of the preset audio data frame a peak PCM sample The audio data frame to which it belongs.
可选的,处理器701在确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:Optionally, the processor 701 determines an offset time of the PCM sample of the first peak in the sine wave of the second amplitude relative to the time at which the belonging audio data frame reaches the recording thread, and meets the following formula:
T=ij%FrameL*1/Samplerate;T=i j %FrameL*1/Samplerate;
其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述设备对所述第二振幅的正弦波进行PCM采样的频率。Wherein the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time; the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents PCM sampling of the second amplitude sine wave by the device Frequency of.
尽管未在图中示出,设备700还可包括通信接口,用于与外部设备进行通信。Although not shown in the figures, device 700 can also include a communication interface for communicating with external devices.
本申请实施例中不限定上述处理器701以及存储器702之间的具体连接介质。本申请实施例在图7中以处理器701以及存储器702之间通过总线连接,图7使用一条空心双箭头线表示,但并不表示仅有一根总线或一种类型的总线,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。总线可以分为地址总线、数据总线、控制总线等。应当指出,设备700可以是如图2所示的终端,可具体执行如图3所示的测试音频回路时延的方法。The specific connection medium between the processor 701 and the memory 702 is not limited in the embodiment of the present application. The embodiment of the present application is connected by a bus between the processor 701 and the memory 702 in FIG. 7. FIG. 7 is represented by a hollow double arrow line, but does not mean that there is only one bus or one type of bus, and other components are The connection method is only for illustrative purposes and is not limited. The bus can be divided into an address bus, a data bus, a control bus, and the like. It should be noted that the device 700 may be a terminal as shown in FIG. 2, and the method of testing the audio loop delay as shown in FIG. 3 may be specifically performed.
具体地,由于本申请上述实施例所提供的设备与本申请前述实施例所提供的方法实施例解决问题的原理相似,因而本申请上述实施例所提供的设备的具体实施以及有益效果可与本申请前述实施例所提供的方法的实施以及有益效果可以相互参见,重复之处不再赘述。The specific implementation and the beneficial effects of the device provided by the foregoing embodiments of the present application may be compared with the foregoing, and the method provided by the foregoing embodiments of the present application is similar to the method for solving the problem. The implementation of the method and the beneficial effects of the method provided by the foregoing embodiments can be referred to each other, and the details are not described again.
在本申请的另一可行实施例中,如图8所示,本申请还提供一种测试音频回路时延的装置800,包括:In another possible embodiment of the present application, as shown in FIG. 8, the present application further provides an apparatus 800 for testing an audio loop delay, including:
开启单元801,用于开启预设的播放线程和录音线程,,所述播放线程用于从所述终端的缓冲区中读取预设音频文件,且经所述终端的扬声器播放所述预设音频文件;所述录音线程用于通过所述终端的麦克风对所述扬声器播放的预设音频文件进行录音;The opening unit 801 is configured to enable a preset playing thread and a recording thread, where the playing thread is configured to read a preset audio file from a buffer of the terminal, and play the preset through a speaker of the terminal An audio file; the recording thread is configured to record a preset audio file played by the speaker through a microphone of the terminal;
确定单元802,用于确定根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述终端的音频回路时延,所述音频回路时延指声音从所述终端的麦克风输入,至从所述终端的扬声器输出的耗时。a determining unit 802, configured to determine, according to the first time information that the playing thread plays the preset audio file, and the second time information that the recording thread records the preset audio file, determine an audio loop of the terminal The audio loop delay refers to the time taken for the sound to be input from the microphone of the terminal to the speaker output from the terminal.
可选的,确定单元802,具体用于:确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息;确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息;根据所述第二时间信息与所述第一时间信息的差值,确定所述终端的音频回路时延。Optionally, the determining unit 802 is specifically configured to: determine that the playing thread plays the first time information of the target data in the preset audio file; and determine that the recording thread records the target data in the preset audio file. Second time information; determining an audio loop delay of the terminal according to a difference between the second time information and the first time information.
可选的,所述预设音频文件为正弦波脉冲编码调制PCM文件,所述正弦波PCM文件为通过对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的;Optionally, the preset audio file is a sine wave pulse code modulation PCM file, and the sine wave PCM file is obtained by performing PCM processing on a sine wave of a first amplitude and a sine wave of a second amplitude;
所述预设音频文件的目标数据为所述第二振幅正弦波中第一个波峰所对应的采样值。The target data of the preset audio file is a sample value corresponding to the first peak of the second amplitude sine wave.
可选的,所述第一振幅的正弦波和第二振幅的正弦波分别所对应的采样值在播放时间上相差第一时长,且所述第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间;Optionally, the sampling value corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ by a first time length in the playing time, and the sampling value corresponding to the sine wave of the first amplitude is played. a play time of a sample value corresponding to a sine wave of the second amplitude earlier than the second amplitude;
确定单元802在确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息时,具体用于:记录所述播放线程启动播放所述预设音频文件的时间信息;根据所述播放线程启动播放所述预设音频文件的时间信息、所述第一振幅的正弦波和第二振幅的正弦波所对应的采样值在播放时间上相差的第一时长,确定所述终端启动播放所述第二振幅的正 弦波所对应的采样值的时间信息;根据所述终端启动播放所述第二振幅的正弦波所对应采样值的时间信息以及所述第二振幅正弦波的周期,确定所述播放线程播放所述第二振幅正弦波中第一个波峰所对应采样值的第一时间信息。The determining unit 802 is configured to: when the playing thread plays the first time information of the target data in the preset audio file, to record time information that the playing thread starts playing the preset audio file; The playing thread starts playing the time information of the preset audio file, the sine wave of the first amplitude and the sampling time corresponding to the sine wave of the second amplitude are different in the playing time, and determining that the terminal starts playing Positive of the second amplitude Time information of the sampled value corresponding to the sine wave; determining, according to the time information of the sampling value corresponding to the sine wave of the second amplitude and the period of the second amplitude sine wave, determining the play thread playing station The first time information of the sample value corresponding to the first peak of the second amplitude sine wave.
可选的,所述预设音频文件包括多帧音频数据,每帧音频数据包括多个PCM样本,每个PCM样本对应于一个PCM采样值;Optionally, the preset audio file includes multi-frame audio data, each frame of audio data includes a plurality of PCM samples, and each PCM sample corresponds to one PCM sample value;
确定单元802在确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息时,具体用于:确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;从音频数据帧与到达录音线程时间的对应关系中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间,所述音频数据帧与到达录音线程时间的对应关系为根据所述预设音频文件中每帧音频数据与到达录音线程的时间所确定的;根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号、音频数据帧的长度以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间的偏移时间;根据所归属音频数据帧到达录制线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。The determining unit 802 is configured to: determine, by the recording thread, the second time information of the target data in the preset audio file, to determine that the PCM sample of the first peak of the second amplitude sine wave belongs to An audio data frame; in a correspondence between the audio data frame and the time of reaching the recording thread, searching for an audio data frame to which the PCM sample of the first peak belongs to correspond to a time of reaching the recording thread, the audio data frame and arrival Corresponding relationship of the recording thread time is determined according to the audio data of each frame in the preset audio file and the time of reaching the recording thread; the sample number of the PCM sample corresponding to the first peak of the sine wave according to the second amplitude a length of the audio data frame and a frequency of PCM sampling the sine wave of the second amplitude, determining that the PCM sample of the first peak of the second amplitude sine wave arrives at the recording thread with respect to the belonging audio data frame Time offset time; determining the recording thread recording station according to the time when the belonging audio data frame arrives at the recording thread and the offset time The second sine amplitude of the first peak of the second time information corresponding to the sampling values.
可选的,确定单元802在确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧时,具体用于:计算所述预设音频文件中每个PCM样本的左梯度和右梯度,所述左梯度指一PCM样本的采样值与相邻的左PCM样本的采样值的差值,所述右梯度指一PCM样本的采样值与相邻的右PCM样本的采样值的差值;从所述预设音频文件的PCM样本中,查找左梯度和右梯度均大于零的PCM样本,建立波峰PCM样本集合;从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样本的采样值,等于相邻的右波峰PCM样本的采样值;根据所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号以及预设的音频数据帧的长度,确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧。Optionally, when determining the audio data frame to which the PCM sample of the first peak in the second amplitude sine wave belongs, the determining unit 802 is specifically configured to: calculate each PCM sample in the preset audio file. Left gradient and right gradient, the left gradient refers to the difference between the sampled value of a PCM sample and the sampled value of an adjacent left PCM sample, the right gradient refers to the sampled value of a PCM sample and the adjacent right PCM sample a difference between the sampled values; from the PCM samples of the preset audio file, finding PCM samples whose left gradient and right gradient are both greater than zero, establishing a peak PCM sample set; and searching for the second amplitude from the peak PCM sample set a PCM sample of a first peak in the sine wave, wherein a sample value corresponding to the PCM sample of the first peak of the second amplitude sine wave is greater than a sample value of the adjacent left peak PCM sample, equal to the adjacent a sample value of the right peak PCM sample; determining a sine wave of the second amplitude according to a sample number of the PCM sample of the first peak of the second amplitude sine wave and a length of the preset audio data frame a peak of PCM Audio frame belongs.
可选的,确定单元802在确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:Optionally, the determining unit 802 determines the offset time of the PCM sample of the first peak in the sine wave of the second amplitude relative to the time of the belonging audio data frame to the recording thread time, and meets the following formula:
T=ij%FrameL*1/Samplerate;T=i j %FrameL*1/Samplerate;
其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述终端对所述第二振幅的正弦波进行PCM采样的频率。Wherein the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time; the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
具体地,由于本申请上述实施例所提供的装置与本申请前述实施例所提供的方法实施例解决问题的原理相似,因而本申请上述实施例所提供的装置的具体实施以及有益效果可与本申请前述实施例所提供的方法的实施以及有益效果可以相互参见,重复之处不再赘述。The specific implementation and beneficial effects of the apparatus provided by the foregoing embodiments of the present application are similar to those of the foregoing embodiments of the present application. The implementation of the method and the beneficial effects of the method provided by the foregoing embodiments can be referred to each other, and the details are not described again.
本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,另外,在本申请各个实施例中的各功能模块可以集成在一个处理器中,也可以是单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。比如,图7或 图2所示设备可以是图8的一种具体实现方式。其中,图8所示的开启单元801和确定单元802的一种实现方式为通过图7所示的处理器701调用存储器702中的计算机存储指令实现。The division of the modules in the embodiment of the present application is schematic, and is only a logical function division. In actual implementation, there may be another division manner. In addition, each functional module in each embodiment of the present application may be integrated into one processing. In the device, it can also be physically existed alone, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. For example, Figure 7 or The device shown in Figure 2 can be a specific implementation of Figure 8. One implementation of the opening unit 801 and the determining unit 802 shown in FIG. 8 is implemented by calling the computer storage instruction in the memory 702 by the processor 701 shown in FIG.
在本申请的另一可行实施例中,还提供一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行测试音频回路时延的方法。In another possible embodiment of the present application, there is also provided a computer readable storage medium comprising instructions for causing a computer to perform a method of testing an audio loop delay when it is run on a computer.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware. Moreover, the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
显然,本领域的技术人员可以对本申请实施例进行各种改动和变型而不脱离本申请实施例的精神和范围。这样,倘若本申请实施例的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。 It is apparent that those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, it is intended that the present invention cover the modifications and variations of the embodiments of the present invention.

Claims (15)

  1. 一种测试音频回路时延的方法,其特征在于,包括:A method for testing an audio loop delay is characterized by comprising:
    终端开启预设的播放线程,所述播放线程用于从所述终端的缓冲区中读取预设音频文件,且经所述终端的扬声器播放所述预设音频文件;The terminal starts a preset playing thread, and the playing thread is configured to read a preset audio file from a buffer of the terminal, and play the preset audio file via a speaker of the terminal;
    所述终端开启预设的录音线程,所述录音线程用于通过所述终端的麦克风对所述扬声器播放的预设音频文件进行录音;The terminal starts a preset recording thread, and the recording thread is configured to record a preset audio file played by the speaker through a microphone of the terminal;
    所述终端根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述终端的音频回路时延,所述音频回路时延指声音从所述终端的麦克风输入,至从所述终端的扬声器输出的耗时。Determining, by the terminal, the audio loop delay of the terminal according to the first time information that the playing thread plays the preset audio file and the second time information that the recording thread records the preset audio file, Audio loop delay refers to the time it takes for sound to be input from the microphone of the terminal to the output from the speaker of the terminal.
  2. 根据权利要求1所述的方法,其特征在于,所述终端根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述终端的音频回路时延,包括:The method according to claim 1, wherein the terminal plays the first time information of the preset audio file according to the playing thread and the second time information of the recording thread recording the preset audio file. Determining the audio loop delay of the terminal, including:
    所述终端确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息;Determining, by the terminal, that the playing thread plays the first time information of the target data in the preset audio file;
    所述终端确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息;Determining, by the terminal, the second time information of the target data in the preset audio file by the recording thread;
    所述终端根据所述第二时间信息与所述第一时间信息的差值,确定所述终端的音频回路时延。The terminal determines an audio loop delay of the terminal according to a difference between the second time information and the first time information.
  3. 根据权利要求2所述的方法,其特征在于,所述预设音频文件为正弦波脉冲编码调制PCM文件,所述正弦波PCM文件为通过对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的;The method of claim 2 wherein said predetermined audio file is a sinusoidal pulse code modulated PCM file, said sinusoidal PCM file being a sine wave passing through a sine wave of a first amplitude and a second amplitude Obtained by PCM processing;
    所述预设音频文件的目标数据为所述第二振幅正弦波中第一个波峰所对应的采样值。The target data of the preset audio file is a sample value corresponding to the first peak of the second amplitude sine wave.
  4. 根据权利要求3所述的方法,其特征在于,所述第一振幅的正弦波和第二振幅的正弦波分别所对应的采样值在播放时间上相差第一时长,且所述第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间;The method according to claim 3, wherein the sampling values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ in play time by a first duration, and the first amplitude The playing time of the sampling value corresponding to the sine wave is earlier than the playing time of the sampling value corresponding to the sine wave of the second amplitude;
    所述终端确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息,包括:Determining, by the terminal, that the playing thread plays the first time information of the target data in the preset audio file, including:
    所述终端记录所述播放线程启动播放所述预设音频文件的时间信息;The terminal records time information that the playing thread starts playing the preset audio file;
    所述终端根据所述播放线程启动播放所述预设音频文件的时间信息、所述第一振幅的正弦波和第二振幅的正弦波所对应的采样值在播放时间上相差的第一时长,确定所述终端启动播放所述第二振幅的正弦波所对应的采样值的时间信息;The first time length of the playback time of the playback time by the playback thread, the sine wave of the first amplitude and the sine wave of the second amplitude are different in the play time, Determining, by the terminal, time information of a sampling value corresponding to the sine wave of the second amplitude being played;
    所述终端根据所述终端启动播放所述第二振幅的正弦波所对应采样值的时间信息以及所述第二振幅正弦波的周期,确定所述播放线程播放所述第二振幅正弦波中第一个波峰所对应采样值的第一时间信息。Determining, by the terminal, the time information of the sampling value corresponding to the sine wave of the second amplitude and the period of the second amplitude sine wave, determining that the playing thread plays the second amplitude sine wave The first time information of the sample value corresponding to a peak.
  5. 根据权利要求3或4所述的方法,其特征在于,所述预设音频文件包括多帧音频数据,每帧音频数据包括多个PCM样本,每个PCM样本对应于一个PCM采样值;The method according to claim 3 or 4, wherein the preset audio file comprises multi-frame audio data, each frame of audio data comprises a plurality of PCM samples, each PCM sample corresponding to one PCM sample value;
    所述终端确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息,包括:Determining, by the terminal, that the recording thread records the second time information of the target data in the preset audio file, including:
    所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;Determining, by the terminal, an audio data frame to which a PCM sample of a first peak of the second amplitude sine wave belongs;
    所述终端从音频数据帧与到达录音线程时间的对应关系中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间,所述音频数据帧与到达录音 线程时间的对应关系为根据所述预设音频文件中每帧音频数据与到达录音线程的时间所确定的;The terminal searches for the time when the audio data frame to which the PCM sample of the first peak belongs belongs to the recording thread, and the audio data frame and the arrival recording, from the correspondence between the audio data frame and the time of the recording thread. The correspondence of the thread time is determined according to the audio data of each frame in the preset audio file and the time of reaching the recording thread;
    所述终端根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号、音频数据帧的长度以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间的偏移时间;Determining, by the terminal, the sample number of the PCM sample corresponding to the first peak of the second amplitude sine wave, the length of the audio data frame, and the frequency of PCM sampling the sine wave of the second amplitude The offset time of the PCM sample of the first peak of the two amplitude sine waves relative to the time at which the assigned audio data frame reaches the recording thread time;
    所述终端根据所归属音频数据帧到达录制线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。And determining, by the terminal, the second time information of the sampling value corresponding to the first peak of the sine wave of the second amplitude by the recording thread according to the time when the belonging audio data frame reaches the recording thread and the offset time.
  6. 根据权利要求5所述的方法,其特征在于,所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧,包括:The method according to claim 5, wherein the terminal determines an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs, comprising:
    所述终端计算所述预设音频文件中每个PCM样本的左梯度和右梯度,所述左梯度指一PCM样本的采样值与相邻的左PCM样本的采样值的差值,所述右梯度指一PCM样本的采样值与相邻的右PCM样本的采样值的差值;The terminal calculates a left gradient and a right gradient of each PCM sample in the preset audio file, where the left gradient refers to a difference between a sample value of a PCM sample and a sample value of an adjacent left PCM sample, the right The gradient refers to the difference between the sampled value of a PCM sample and the sampled value of an adjacent right PCM sample;
    所述终端从所述预设音频文件的PCM样本中,查找左梯度和右梯度均大于零的PCM样本,建立波峰PCM样本集合;The terminal searches for PCM samples whose left gradient and right gradient are greater than zero from the PCM samples of the preset audio file, and establishes a peak PCM sample set;
    所述终端从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样本的采样值,等于相邻的右波峰PCM样本的采样值;The terminal searches for a PCM sample of a first peak of a second amplitude sine wave from the set of peak PCM samples, wherein a sampling corresponding to a PCM sample of a first peak of the second amplitude sine wave The value is greater than the sample value of the adjacent left peak PCM sample, which is equal to the sample value of the adjacent right peak PCM sample;
    所述终端根据所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号以及预设的音频数据帧的长度,确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧。Determining, by the terminal, the PCM sample of the first peak of the second amplitude sine wave according to the sample number of the PCM sample of the first peak of the second amplitude sine wave and the length of the preset audio data frame The audio data frame to which it belongs.
  7. 根据权利要求5或6所述的方法,其特征在于,所述终端确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:The method according to claim 5 or 6, wherein the terminal determines the offset of the PCM sample of the first peak of the second amplitude sine wave relative to the time of the assigned audio data frame to the recording thread time Time, in accordance with the following formula:
    T=ij%FrameL*1/Samplerate;T=i j %FrameL*1/Samplerate;
    其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述终端对所述第二振幅的正弦波进行PCM采样的频率。Wherein the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time; the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents the terminal to perform PCM sampling on the second amplitude sine wave Frequency of.
  8. 一种测试音频回路时延的设备,其特征在于,所述设备包括处理器和存储器;A device for testing an audio loop delay, characterized in that the device comprises a processor and a memory;
    所述处理器,用于读取所述存储器中的代码,以用于执行:开启预设的播放线程,所述播放线程用于从所述设备的缓冲区中读取预设音频文件,且经所述设备的扬声器播放所述预设音频文件;开启预设的录音线程,所述录音线程用于通过所述设备的麦克风对所述扬声器播放的预设音频文件进行录音;根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述设备的音频回路时延,所述音频回路时延指声音从所述设备的麦克风输入,至从所述设备的扬声器输出的耗时。The processor is configured to read code in the memory for performing: starting a preset playing thread, the playing thread is configured to read a preset audio file from a buffer of the device, and Playing the preset audio file through a speaker of the device; opening a preset recording thread, wherein the recording thread is configured to record a preset audio file played by the speaker through a microphone of the device; Determining, by the thread, the first time information of the preset audio file and the second time information of the recording thread recording the preset audio file, determining an audio loop delay of the device, where the audio loop delay refers to sound from The microphone input of the device is time consuming to output from the speaker of the device.
  9. 根据权利要求8所述的设备,其特征在于,所述处理器在根据所述播放线程播放所述预设音频文件的第一时间信息以及所述录音线程录制所述预设音频文件的第二时间信息,确定所述设备的音频回路时延时,具体用于:The device according to claim 8, wherein the processor plays the first time information of the preset audio file according to the playing thread and the second recording of the preset audio file by the recording thread Time information, determining the time delay of the audio loop of the device, specifically for:
    确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息; Determining, by the playing thread, the first time information of the target data in the preset audio file;
    确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息;Determining, by the recording thread, second time information of the target data in the preset audio file;
    根据所述第二时间信息与所述第一时间信息的差值,确定所述设备的音频回路时延。Determining an audio loop delay of the device according to a difference between the second time information and the first time information.
  10. 根据权利要求9所述的设备,其特征在于,所述预设音频文件为正弦波脉冲编码调制PCM文件,所述正弦波PCM文件为通过对第一振幅的正弦波和第二振幅的正弦波进行PCM处理所获得的;The apparatus according to claim 9, wherein said predetermined audio file is a sine wave pulse code modulation PCM file, said sine wave PCM file being a sine wave passing through a sine wave of a first amplitude and a second amplitude Obtained by PCM processing;
    所述预设音频文件的目标数据为所述第二振幅正弦波中第一个波峰所对应的采样值。The target data of the preset audio file is a sample value corresponding to the first peak of the second amplitude sine wave.
  11. 根据权利要求10所述的设备,其特征在于,所述第一振幅的正弦波和第二振幅的正弦波分别所对应的采样值在播放时间上相差第一时长,且所述第一振幅的正弦波所对应的采样值的播放时间早于所述第二振幅的正弦波所对应的采样值的播放时间;The apparatus according to claim 10, wherein the sampling values corresponding to the sine wave of the first amplitude and the sine wave of the second amplitude respectively differ in play time by a first duration, and the first amplitude The playing time of the sampling value corresponding to the sine wave is earlier than the playing time of the sampling value corresponding to the sine wave of the second amplitude;
    所述处理器在确定所述播放线程播放所述预设音频文件中目标数据的第一时间信息时,具体用于:When determining, by the processor, the first time information of the target data in the preset audio file, the processor is specifically configured to:
    记录所述播放线程启动播放所述预设音频文件的时间信息;Recording time information that the playing thread starts playing the preset audio file;
    根据所述播放线程启动播放所述预设音频文件的时间信息、所述第一振幅的正弦波和第二振幅的正弦波所对应的采样值在播放时间上相差的第一时长,确定所述设备启动播放所述第二振幅的正弦波所对应的采样值的时间信息;Determining, according to the time period in which the playing thread starts playing the preset audio file, the sine wave of the first amplitude, and the sampling time corresponding to the sine wave of the second amplitude are different in the playing time. The device starts playing time information of the sample value corresponding to the sine wave of the second amplitude;
    根据所述设备启动播放所述第二振幅的正弦波所对应采样值的时间信息以及所述第二振幅正弦波的周期,确定所述播放线程播放所述第二振幅正弦波中第一个波峰所对应采样值的第一时间信息。Determining, by the device, the time information of the sampling value corresponding to the sine wave of the second amplitude and the period of the second amplitude sine wave, determining that the playing thread plays the first peak of the second amplitude sine wave The first time information of the corresponding sampled value.
  12. 根据权利要求10或11所述的设备,其特征在于,所述预设音频文件包括多帧音频数据,每帧音频数据包括多个PCM样本,每个PCM样本对应于一个PCM采样值;The device according to claim 10 or 11, wherein the preset audio file comprises multi-frame audio data, each frame of audio data comprises a plurality of PCM samples, each PCM sample corresponding to one PCM sample value;
    所述处理器在确定所述录音线程录制所述预设音频文件中目标数据的第二时间信息时,具体用于:When the processor determines that the recording thread records the second time information of the target data in the preset audio file, the processor is specifically configured to:
    确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧;Determining an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs;
    从音频数据帧与到达录音线程时间的对应关系中,查找所述第一个波峰的PCM样本所归属的音频数据帧对应到达所述录制线程的时间,所述音频数据帧与到达录音线程时间的对应关系为根据所述预设音频文件中每帧音频数据与到达录音线程的时间所确定的;From the correspondence between the audio data frame and the time of reaching the recording thread, searching for the time when the audio data frame to which the PCM sample of the first peak belongs belongs to the recording thread, the audio data frame and the time of reaching the recording thread Corresponding relationship is determined according to each frame of audio data in the preset audio file and the time of reaching the recording thread;
    根据所述第二振幅的正弦波的第一个波峰所对应PCM样本的样本编号、音频数据帧的长度以及对所述第二振幅的正弦波进行PCM采样的频率,确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录制线程时间的偏移时间;Determining the second amplitude according to a sample number of the PCM sample corresponding to the first peak of the second amplitude sine wave, a length of the audio data frame, and a frequency of PCM sampling the sine wave of the second amplitude The offset time of the PCM sample of the first peak in the sine wave relative to the time at which the assigned audio data frame reaches the recording thread time;
    根据所归属音频数据帧到达录制线程的时间和所述偏移时间,确定所述录音线程录制所述第二振幅的正弦波中第一个波峰所对应采样值的第二时间信息。And determining, according to the time when the belonging audio data frame arrives at the recording thread and the offset time, the recording thread to record the second time information of the sample value corresponding to the first peak of the sine wave of the second amplitude.
  13. 根据权利要求12所述的设备,其特征在于,所述处理器在确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧时,具体用于:The apparatus according to claim 12, wherein the processor is configured to: when determining an audio data frame to which the PCM sample of the first peak of the second amplitude sine wave belongs;
    计算所述预设音频文件中每个PCM样本的左梯度和右梯度,所述左梯度指一PCM样本的采样值与相邻的左PCM样本的采样值的差值,所述右梯度指一PCM样本的采样值与相邻的右PCM样本的采样值的差值;Calculating a left gradient and a right gradient of each PCM sample in the preset audio file, the left gradient being a difference between a sample value of a PCM sample and a sample value of an adjacent left PCM sample, the right gradient being a The difference between the sampled value of the PCM sample and the sampled value of the adjacent right PCM sample;
    从所述预设音频文件的PCM样本中,查找左梯度和右梯度均大于零的PCM样本,建立波峰PCM样本集合;From the PCM samples of the preset audio file, searching for PCM samples whose left gradient and right gradient are both greater than zero, and establishing a peak PCM sample set;
    从所述波峰PCM样本集合中,查找第二振幅的正弦波中第一个波峰的PCM样本,其中,所述第二振幅的正弦波中第一个波峰的PCM样本所对应的采样值大于相邻的左波峰PCM样 本的采样值,等于相邻的右波峰PCM样本的采样值;From the set of peak PCM samples, searching for a PCM sample of a first peak of a second amplitude sine wave, wherein a sample value corresponding to a PCM sample of the first peak of the second amplitude sine wave is greater than a phase Adjacent left peak PCM The sampled value is equal to the sampled value of the adjacent right peak PCM sample;
    根据所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号以及预设的音频数据帧的长度,确定所述第二振幅的正弦波中第一个波峰的PCM样本所归属的音频数据帧。Determining, according to a sample number of the PCM sample of the first peak of the second amplitude sine wave and a length of the preset audio data frame, determining a PCM sample of the first peak of the second amplitude sine wave belongs to Audio data frame.
  14. 根据权利要求12或13所述的设备,其特征在于,所述处理器在确定所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间,符合下述公式要求:The apparatus according to claim 12 or 13, wherein said processor determines that the PCM sample of the first peak of said second amplitude sine wave arrives at the recording thread time with respect to the belonging audio data frame Offset time, in accordance with the following formula:
    T=ij%FrameL*1/Samplerate;T=i j %FrameL*1/Samplerate;
    其中,所述T代表所述第二振幅的正弦波中第一个波峰的PCM样本相对于所归属的音频数据帧到达录音线程时间的偏移时间;所述ij代表所述第二振幅的正弦波中第一个波峰的PCM样本的样本编号;所述FrameL代表音频数据帧的长度,所述%代表求余,所述Samplerate代表所述设备对所述第二振幅的正弦波进行PCM采样的频率。Wherein the T represents an offset time of a PCM sample of the first peak of the second amplitude sine wave relative to a time at which the assigned audio data frame reaches a recording thread time; the i j represents the second amplitude The sample number of the PCM sample of the first peak in the sine wave; the FrameL represents the length of the audio data frame, the % represents the remainder, and the Samplerate represents PCM sampling of the second amplitude sine wave by the device Frequency of.
  15. 一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得计算机执行如权利要求1至7任意一项所述的方法。 A computer readable storage medium, comprising instructions that, when run on a computer, cause the computer to perform the method of any one of claims 1 to 7.
PCT/CN2017/082238 2016-12-30 2017-04-27 Method and device for testing latency of audio loop WO2018120545A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201780009092.1A CN108702568B (en) 2016-12-30 2017-04-27 Method and equipment for testing time delay of audio loop

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611264801 2016-12-30
CN201611264801.4 2016-12-30

Publications (1)

Publication Number Publication Date
WO2018120545A1 true WO2018120545A1 (en) 2018-07-05

Family

ID=62707668

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/082238 WO2018120545A1 (en) 2016-12-30 2017-04-27 Method and device for testing latency of audio loop

Country Status (2)

Country Link
CN (1) CN108702568B (en)
WO (1) WO2018120545A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111381954A (en) * 2018-12-27 2020-07-07 深圳市优必选科技有限公司 Audio data recording method, system and terminal equipment
CN112073879A (en) * 2020-09-11 2020-12-11 成都极米科技股份有限公司 Audio synchronous playing method and device, video playing equipment and readable storage medium
CN113593570A (en) * 2021-07-28 2021-11-02 深圳创维-Rgb电子有限公司 Voice abnormity diagnosis method, device, equipment and storage medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110931053B (en) * 2019-12-09 2021-10-08 广州酷狗计算机科技有限公司 Method, device, terminal and storage medium for detecting recording time delay and recording audio
CN113381899B (en) * 2020-02-25 2023-09-22 福建天泉教育科技有限公司 Method and system for testing first acoustic delay in screen throwing technology
CN113688656A (en) * 2020-05-19 2021-11-23 福建天泉教育科技有限公司 Method and system for testing sound delay in screen projection software

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6970568B1 (en) * 1999-09-27 2005-11-29 Electronic Engineering And Manufacturing Inc. Apparatus and method for analyzing an electro-acoustic system
CN1952628A (en) * 2005-10-18 2007-04-25 索尼株式会社 Sound measuring apparatus and method, and audio signal processing apparatus
CN101448186A (en) * 2007-11-26 2009-06-03 鸿富锦精密工业(深圳)有限公司 System and method for automatic regulating sound effect of a loudspeaker
CN102325059A (en) * 2011-09-09 2012-01-18 华南理工大学 Audio frequency end-to-end time delay measurement method of non-intrusive single end acquisition and apparatus thereof
CN104778950A (en) * 2014-01-15 2015-07-15 华平信息技术股份有限公司 Microphone signal delay compensation control method based on echo cancellation

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2528135B2 (en) * 1987-07-28 1996-08-28 株式会社日立製作所 Acoustic simulator
KR101149448B1 (en) * 2007-02-12 2012-05-25 삼성전자주식회사 Audio encoding and decoding apparatus and method thereof
CN102568494B (en) * 2012-02-23 2014-02-05 贵阳朗玛信息技术股份有限公司 Optimized method, device and system for eliminating echo
CN104394286A (en) * 2014-08-27 2015-03-04 贵阳朗玛信息技术股份有限公司 Echo cancellation method and device
CN205566643U (en) * 2016-04-28 2016-09-07 湖南工业大学 Audio frequency winding automatic test system
CN106210371B (en) * 2016-08-31 2018-09-18 广州视源电子科技股份有限公司 A kind of the determination method, apparatus and intelligent meeting equipment of echo delay time

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6970568B1 (en) * 1999-09-27 2005-11-29 Electronic Engineering And Manufacturing Inc. Apparatus and method for analyzing an electro-acoustic system
CN1952628A (en) * 2005-10-18 2007-04-25 索尼株式会社 Sound measuring apparatus and method, and audio signal processing apparatus
CN101448186A (en) * 2007-11-26 2009-06-03 鸿富锦精密工业(深圳)有限公司 System and method for automatic regulating sound effect of a loudspeaker
CN102325059A (en) * 2011-09-09 2012-01-18 华南理工大学 Audio frequency end-to-end time delay measurement method of non-intrusive single end acquisition and apparatus thereof
CN104778950A (en) * 2014-01-15 2015-07-15 华平信息技术股份有限公司 Microphone signal delay compensation control method based on echo cancellation

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111381954A (en) * 2018-12-27 2020-07-07 深圳市优必选科技有限公司 Audio data recording method, system and terminal equipment
CN112073879A (en) * 2020-09-11 2020-12-11 成都极米科技股份有限公司 Audio synchronous playing method and device, video playing equipment and readable storage medium
CN113593570A (en) * 2021-07-28 2021-11-02 深圳创维-Rgb电子有限公司 Voice abnormity diagnosis method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN108702568B (en) 2020-04-21
CN108702568A (en) 2018-10-23

Similar Documents

Publication Publication Date Title
WO2018120545A1 (en) Method and device for testing latency of audio loop
CN105872253B (en) Live broadcast sound processing method and mobile terminal
US10785541B2 (en) Screencast recording method, screencast playing method, screen recording terminal, and playing terminal
CN110265064B (en) Audio frequency crackle detection method, device and storage medium
CN102348150A (en) Audio signal processing apparatus, audio signal processing method, and program
CN109600564B (en) Method and apparatus for determining a timestamp
CN105391837A (en) Method and apparatus for managing audio signals
KR20150121038A (en) Voice-controlled communication connections
WO2020024962A1 (en) Method and apparatus for processing data
WO2018219165A1 (en) Music playback method, terminal, and storage medium
US20240054157A1 (en) Song recommendation method and apparatus, electronic device, and storage medium
CN109600661B (en) Method and apparatus for recording video
CN104064212A (en) Sound recording method and device
WO2020024949A1 (en) Method and apparatus for determining timestamp
CN1980437B (en) Method and device for making sound effect in the mobile terminal
WO2023169259A1 (en) Music popularity prediction method and apparatus, storage medium, and electronic device
CN113726600B (en) Transmission delay determining method, device, terminal and storage medium
CN104835500A (en) Method and device for acquiring audio information
CN111147655B (en) Model generation method and device
JP2017203931A (en) Acoustic property measurement device and acoustic property measurement method
WO2016107178A1 (en) Method and device for playing ring back tone
CN108335706B (en) Seamless playing method of multimedia file, terminal equipment and storage medium
JP2005274991A (en) Musical data storing device and deleting method of overlapped musical data
CN103929544A (en) Method and system for realizing automatic sound recording of pc-side and mobile terminal
CN113674739B (en) Time determination method, device, equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17889331

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17889331

Country of ref document: EP

Kind code of ref document: A1