A method, system, and storage medium for drawing and scaling audio waveforms.
By employing segmented drawing and gesture monitoring on Android devices, the memory overflow and stuttering issues when drawing ultra-large audio waveforms on Android devices were resolved, achieving efficient and smooth audio waveform display and scaling.
Patent Information
- Application Number
- CN202310107787.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-02-14
AI Technical Summary
When drawing extremely large audio waveforms on Android devices, existing technologies are prone to memory overflow (OOM) and stuttering issues, especially when processing very long audio data. Common solutions such as disabling hardware acceleration and using WebView or BitmapRegionDecoder have various limitations and defects.
A segmented drawing method is adopted, and calculations and redrawing are performed only when the main segments change. By listening to swipe and zoom gestures, the waveform is calculated in real time and drawn segment by segment on the view control, avoiding drawing the entire waveform at once.
It significantly improves the efficiency of waveform drawing, avoids memory overflow issues, and ensures a smooth display and scaling experience.
Smart Images

Figure CN116343818B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of audio processing, and particularly relates to a method and system for drawing and scaling an audio waveform graph based on Android and a storage medium. BACKGROUND
[0002] An audio waveform graph is a curve or polyline used to display uniformly collected sound data at a specified sampling rate, with the abscissa representing time and the ordinate representing the amplitude intensity of an audio signal. The amplitude intensity data changes over time, and each data point is uniformly distributed along the x-axis. When processing amplitude data, the value of x is incremented by a fixed drawing step T, and the value of y is stored in a one-dimensional array y[] to store the amplitude intensity data, such as y[0] = a0, y[1] = a1, y[2] = a2... y[n] = an. When taking values, an array index variable i is defined with an initial value of 0, and the variable i is incremented by 1 in each loop, i.e. i = 1, 2, 3... n. Then, the corresponding values of x and y are obtained every time the loop is executed, x = i x T, y = y[i], and the coordinates (x, y) are obtained one by one. After connecting all the coordinates in sequence, the waveform graph of the audio is obtained.
[0003] For the drawing and display of a waveform graph, taking a common Android mobile phone with a resolution of 1080*1920 pixels as an example, the default vertical screen display is used. When x > 1080, the waveform graph will exceed the screen display range, and can be viewed by dragging left and right. When the value of x is large, for example, when processing a 5-hour conference recording of a 48000Hz sampling rate single-channel, 864000000 audio sample data will be obtained. Assuming that one amplitude data contains 1200 samples, i.e. 720000 amplitude data, and the drawing step T is 2, i.e. one amplitude data is drawn every 2 pixels along the x-axis, the final value of x is 1440000, i.e. the length of the entire waveform graph is 1440000 pixels, which is a very long waveform graph. If it is drawn and displayed on the mobile phone at once, due to the influence of CPU, GPU, memory and other hardware configurations, when 720000 amplitude data is read and drawn, the data loading may be slow and the screen may be frozen. During the display and waveform graph refreshing process, the screen edges may be white, and even an Out Of Memory (OOM) exception may be caused, affecting the user experience.
[0004] On an Android device, when the above-mentioned super-long waveform graph is directly loaded and displayed, an OOM exception usually occurs.
[0005] Common solutions and problems in the prior art include:
[0006] 1. Disable hardware acceleration. Disabling hardware acceleration allows for larger images to be displayed, but the image size still cannot exceed a certain limit. Furthermore, disabling hardware acceleration can cause the app to lag, affecting the user experience.
[0007] 2. Using WebView for loading and rendering, but when the image memory reaches the MB level, WebView will also crash and will be unable to draw the very long audio waveform.
[0008] 3. Use BitmapRegionDecoder or a third-party API that wraps BitmapRegionDecoder. BitmapRegionDecoder is a utility class provided by Android that can decode and display a specified rectangular area of an image. It is used for loading images in chunks, but requires handling swipe and zoom gestures manually. Third-party APIs wrap BitmapRegionDecoder, handling swipe and zoom gestures, making them convenient to use. This method can easily load and display very large and long images. However, in the application scenario of audio waveform diagrams, there is actually no "image" in reality. Instead, sample data is obtained through sampling, and amplitude data is obtained by calculating the sample data within a unit of time. All the amplitude data of an audio can be drawn into a waveform diagram and saved as an image, and then loaded and displayed using this solution. However, firstly, the image itself occupies storage space; secondly, after editing the audio, the image needs to be regenerated, which is inconvenient for users; thirdly, when scaling, the image is scaled directly, which may result in blurring or jagged edges, and cannot accurately reproduce the scaled audio waveform diagram. Summary of the Invention
[0009] To address the above problems, the first aspect of this invention proposes an audio waveform drawing method based on Android, comprising the following steps:
[0010] Obtain audio amplitude data;
[0011] The audio is segmented by length, with the length of each segment being the width of the device screen. The segment currently swiping across the left side of the screen is determined as the main segment, and waveforms of several segments to the right or left and right sides of the main segment are drawn.
[0012] Monitor the waveform's movement; when the main segment changes, redraw the waveform of the current main segment and several segments to the left and right of the main segment.
[0013] The above scheme does not generate pictures and does not load pictures, but listens to the swiping gesture, calculates in real time and performs segmented drawing on the view control, only draws the segment of the waveform graph displayed by the current display device, and pre-draws the segment to be displayed according to the swiping direction. At this time, only calculation and redrawing can be performed when the main segment is switched each time, thereby significantly improving the drawing efficiency of the waveform graph.
[0014] Further, the main segment is determined according to the swiping gesture, if the waveform graph is swiped to the left, the audio waveform graph of the main segment and at least two segments on the right of the main segment is drawn; if the waveform graph is swiped to the right, the audio waveform graph of the main segment and at least one segment on the left and right of the main segment is drawn. By judging the swiping direction and pre-drawing the waveform of part of the segment, it can be ensured that there is no lag and blank at the edge of the screen when the waveform graph is scrolled, and the smoothness is enhanced. Preparation with three segments shows better performance in practice. Figure 1
[0015] Further, the starting point of the coordinate y-axis is the height of the drawing view control, and the waveform graph is drawn from the bottom of the control upwards, which is more in line with user habits visually.
[0016] Further, the step of drawing the waveform graph specifically comprises:
[0017] Calculate the number of waveform amplitudes pointPerScreen to be drawn in one screen width
[0018] pointPerScreen = screenWidth / T
[0019] Wherein, screenWidth is the screen width, and T is the drawing step;
[0020] Calculate the current main segment index currentIndex
[0021] currentIndex = scrollX / screenWidth
[0022] Wherein, scrollX is the horizontal scroll offset of the horizontal scroll container, and screenWidth is the screen width;
[0023] If the screen is swiped to the left, the startIndex of the waveform graph is currentIndex*pointPerScreen
[0024] endIndex = (currentIndex+n)*pointPerScreen
[0025] Wherein, the startIndex is a start index, the endIndex is an end index, and n is a total number of segments to be drawn; if the screen is swiped to the right, the wave graph is drawn
[0026] startIndex = (currentIndex-n1)*pointPerScreen
[0027] endIndex = (currentIndex+1+n2)*pointPerScreen
[0028] Wherein, n1 is a number of segments on the left side of the main segment, and n2 is a number of segments on the right side of the main segment.
[0029] The second aspect of the present application provides an audio wave graph scaling method based on Android, comprising the steps of:
[0030] S21, drawing a wave graph by using any method of the first aspect;
[0031] S22, listening to a scaling gesture, recording a scaling ratio scale, and scaling the wave graph according to the scaling ratio scale.
[0032] Further, the drawing step T is changed according to the scaling ratio scale.
[0033] Further, the drawing index increment is changed according to the scaling ratio scale, and at this time, the drawing step can not be changed, so that the scaling does not affect the drawing performance.
[0034] The third aspect of the present application provides an audio wave graph drawing system based on Android, comprising:
[0035] An amplitude data acquisition module configured to acquire audio amplitude data;
[0036] A wave graph pre-drawing module configured to segment the audio by length, the length of each segment being the width of the device screen, to determine the segment currently swiped on the left side of the screen as a main segment, and to draw a wave graph of a plurality of segments on the right side or on both sides of the main segment;
[0037] A swiping state listening module configured to listen to the swiping state of the wave graph, and to re-draw the wave graph of the current main segment and a plurality of segments on both sides of the main segment when the main segment changes.
[0038] The fourth aspect of the present application provides an audio wave graph scaling system based on Android, comprising:
[0039] A wave graph drawing module configured to draw a wave graph by using any method of the first aspect;
[0040] A zoom gesture listening module configured to listen to a zoom gesture, record a zoom scale scale, and scale the waveform graph according to the zoom scale scale.
[0041] The fifth aspect of the present application provides a computer readable storage medium for Android-based audio waveform graph drawing or zooming, which stores one or more computer programs, and the one or more computer programs are executed by a computer processor to implement any of the above methods.
[0042] The present application provides a method and system for drawing an audio waveform graph on an Android device. Since the segmented processing method is used, only calculation and redrawing are performed when switching the main segment each time, which can significantly improve the drawing efficiency of the waveform graph and realize smooth refresh of the audio waveform graph. At the same time, only a small part of the waveform graph needs to be drawn each time, compared with the method of drawing the entire waveform graph at one time, the OOM (Out Of Memory) problem caused by insufficient memory of the device can be effectively avoided when processing a super-long waveform graph. BRIEF DESCRIPTION OF DRAWINGS
[0043] The accompanying drawings are used to further understand the present application. The elements of the drawings are not necessarily in proportion to each other. For ease of description, only the parts related to the present application are shown in the drawings.
[0044] Figure 2 A flowchart of an Android-based audio waveform graph drawing method in an embodiment;
[0045] Figure 3 A drawing segment diagram when the screen is swiped to the left in another embodiment;
[0046] Figure 4 A drawing segment diagram when the screen is swiped to the right in another embodiment;
[0047] Figure 5 A waveform graph drawing diagram when the y-axis origin coordinate is set as the control height in another embodiment;
[0048] Figure 6 A waveform graph drawing diagram with the upper left corner of the control as the coordinate origin in the prior art;
[0049] Figure 1 A structure diagram of an Android-based audio waveform graph drawing system in another embodiment. DETAILED DESCRIPTION
[0050] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application.
[0051] The first aspect of the present application provides an Android-based audio waveform drawing method, which adopts segmented drawing of waveform. Figure 2 For an embodiment of the Android-based audio waveform drawing method flowchart, a segmented waveform is drawn, wherein a segment of the waveform is a waveform of one screen width; the method comprises the following steps:
[0052] S1, obtaining audio amplitude data. Specifically, the following steps are included:
[0053] a) using the FFmpeg tool library to decode the audio file, in the embodiment, the resampling frequency of the audio is 48000Hz, the resampling bit number is 32bit, and the decoded audio file in the wav format contains original PCM data;
[0054] b) calculating the number of PCM bytes to be read for each waveform data;
[0055] c) traversing the PCM data from the audio file, in the embodiment, 9600 bytes of data are read each time, converted into 2400 float data and stored in a float[] array pcmFloats, then the data obtained in the array is subjected to root mean square calculation to obtain an amplitude data rms, and the rms value obtained each time is stored in a float[] array rmsFloats, i.e., an amplitude data array;
[0056] d) traversing the amplitude data array rmsFloats to obtain the maximum amplitude data rmsMax;
[0057] e) calculating the scale value scaleY of the control height viewHeight and the maximum amplitude data rmsMax, which is used to limit the maximum value of the y-axis to not exceed the height of the drawing view control, wherein the scale value scaleY = rmsMax / viewHeight
[0058] f) traversing the amplitude data array rmsFloats, obtaining the actual y-coordinate of each amplitude data by calculating rms / scaleY, and sequentially storing the y-coordinate in the array y[].
[0059] In a specific embodiment, the leftmost side of the waveform to be drawn is the x-axis 0 coordinate point, the waveform to be drawn is segmented in units of "one screen width (screenWidth)", and only the amplitude data of three segments of the waveform is drawn each time.
[0060] S2, segmenting the audio by length, the length of each segment being the screen width of the device, determining the segment currently crossing the left side of the screen as the main segment, and drawing the waveform of the segments on the right side or the left and right sides of the main segment.
[0061] S3, listening to the waveform chart swipe state, when the main section changes, redraw the current main section and the waveform chart of several sections on the left and right of the main section.
[0062] Specifically, if the waveform chart is swiped to the left, the audio waveform chart of the main section and at least two sections on the right of the main section is drawn; if the waveform chart is swiped to the right, the audio waveform chart of the main section and at least one section on the left and right of the main section is drawn. Figure 2 The drawing of the section diagram when the waveform chart is swiped to the left in the embodiment is shown in the figure, wherein the solid line box is currently swiped to the left of the device screen, which is the main section, and the solid line box and the dashed line box are the currently drawn sections. When drawing for the first time, there is no swipe operation, and the default drawing mode is Figure 3 ; Figure 4 The drawing of the section diagram when the waveform chart is swiped to the right in the embodiment is shown in the figure, wherein the solid line box is currently swiped to the right of the device screen, which is the main section, and the solid line box and the dashed line box are the currently drawn sections.
[0063] In another specific embodiment, the specific steps of drawing the audio waveform chart include:
[0064] 1. Obtain the amplitude data to be drawn into a one-dimensional array y[];
[0065] 2. Use a horizontal scroll control HorizontalScrollView as a container, which contains a view control View for drawing;
[0066] 3. Set the total length of the image to be drawn as the width of the horizontal scroll container and the drawing view control; wherein the total length of the image to be drawn is N x T, N is the total number of amplitude data to be drawn, and T is the step length of each drawing;
[0067] 4. Define a scale value scaleY to limit the maximum value of the waveform chart y-axis from exceeding the height of the drawing view control, the scale value scaleY = yMax / viewHeight, wherein viewHeight is the control height, and yMax is the maximum amplitude data;
[0068] 5. Calculate the number of amplitude points that can be displayed per section, i.e. the number of amplitude points to be drawn per screen width pointPerScreen
[0069] pointPerScreen = screenWidth / T
[0070] Wherein, screenWidth is the screen width, and T is the drawing step length;
[0071] For example, screen width screenwidth is 1080px, drawing step T is 2px, the number of amplitude data that can be displayed per unit segment is pointPerScreen = screenwidth / T = 1080 / 2 = 540;
[0072] 6、The index currentIndex of the current main segment is calculated by the horizontal scroll offset scrollX of the horizontal scroll container, and the result is rounded off;
[0073] currentIndex = scrollX / screenwidth
[0074] 7、The index interval of the amplitude data to be drawn is calculated according to the redraw rule through the main segment index and the horizontal scroll direction of the waveform chart. For example, when the number of segments drawn each time is 3,
[0075] When drawing to the left:
[0076] The start index startIndex = currentIndex*pointPerScreen
[0077] The end index endIndex = (currentIndex+3)*pointPerScreen
[0078] When drawing to the right:
[0079] The start index startIndex = (currentIndex-1)*pointPerScreen
[0080] The end index endIndex = (currentIndex+2)*pointPerScreen
[0081] 8、The x-axis drawing origin xOrign is calculated according to the index interval of the amplitude data to be drawn;
[0082] xOrign = startIndex*T
[0083] 9、Through a loop of a index variable i from startIndex to endIndex, the amplitude data of the corresponding index in the one-dimensional array y[] is read each time, the x-axis coordinate starts from xOrign, the y-coordinate is the read value y[i] / scaleY, and the line segment is drawn, the endpoint of the current line segment is the starting point of the next drawing, and the x-axis coordinate is increased by step T each time. The drawing coordinates obtained each time are (xOrign+T*i, y[i]*scaleY);
[0084] In a further preferred embodiment, the y-axis starting point coordinate is set as the control height, and the y-axis drawing coordinate obtained in each loop is y[i]*scaleY*(-1), and the x-axis is positive to the right, Figure 5 A waveform diagram drawn when the y-axis starting point coordinate is set as the control height is shown in FIG. 4. At this time, the waveform is drawn from the bottom of the control to the top, and a waveform in the first quadrant of the plane coordinate system is obtained. Most of the prior art devices take the upper left corner of the control as the coordinate origin (0, 0), the x-axis is positive to the right, which is consistent with the plane coordinate system; and the y-axis is positive downward, which is opposite to the plane coordinate system, i.e., the waveform is drawn from the top of the control to the bottom, Figure 6 A waveform diagram drawn when the upper left corner of the control is taken as the coordinate origin is shown in FIG. 5. At this time, a waveform that is mirror-symmetric to the expected x-axis is obtained, i.e., the drawn waveform is located in the fourth quadrant of the plane coordinate system.
[0085] The second aspect of the present application provides an audio waveform zooming method based on Android, which comprises the following steps:
[0086] S21, drawing a waveform by using any method of the first aspect;
[0087] S22, listening to a zooming gesture, recording a zooming scale scale, and zooming the waveform according to the zooming scale scale.
[0088] In a specific embodiment, a floating-point variable scale is defined to record the zooming scale, and the default value is 1.0. A zooming gesture on the horizontal scroll control HorizontalScrollView is listened to. When zooming out, the scale is reduced, and when zooming in, the scale is increased. The waveform is zoomed synchronously. Specifically, the zooming gesture listening method is programmed by using a custom class WaveHorizontalScrollView that inherits from HorizontalScrollView. A listening interface ScrollViewListener is defined, an interface method onScaleChange(float scale) is defined to listen to the current zooming scale, and an interface method onScaleComplete(float scale) is defined to listen to the zooming completion. The onTouchEvent(MotionEvent event) method of WaveHorizontalScrollView is rewritten. When two fingers touch the screen at the same time, i.e., the value of event.getPointerCount() is 2, the following is judged:
[0089] When the second finger touches the screen, the distance lenStar between the touch points of the two fingers at the zooming start is calculated;
[0090] When two fingers move, the distance between the current two-finger touch points lenEnd is calculated, and the current zoom scale increment ratio scaleOffset is calculated according to lenStar and lenEnd, the final zoom scale totalScale is calculated using scale*scaleOffset, and the onScaleChange(totalScale) method is called to inform the UI to perform the corresponding zoom process;
[0091] When one of the two fingers leaves the screen, the onScaleChange(totalScale) method is called to inform the UI to perform the corresponding zoom completion processing.
[0092] In a specific embodiment, the waveform graph is scaled. The drawing step T is changed according to the zoom scale scale, when T increases, the waveform graph is enlarged, and when T decreases, the waveform graph is reduced, that is, the scaled step T is assigned as T*scale. Since the drawing step T changes, the number of amplitude data of each segment also changes, and the step T and the number of amplitudes are inversely proportional, that is, when T increases, the number of segmented amplitude data decreases, and when T decreases, the number of segmented amplitude data increases. The number of segmented amplitude data has a certain impact on the drawing performance.
[0093] In another preferred embodiment, the waveform graph is scaled by density. The drawing step T is kept unchanged, and the array index variable i in the loop during the drawing process is recalculated according to the zoom scale scale, and i is incremented by 1 / scale (i+=1 / scale, rounded up), that is, the increment of i is not an integer of 1, but a floating-point decimal, for example, when the zoom scale scale is 0.5, the waveform graph is reduced to 50% of the original, then i+=2, i=0, 2, 4, 6, 8……. At this time, part of the amplitude data values are skipped during the loop drawing of the waveform graph, that is, the amplitude data in the skipped part is not drawn. In this embodiment, since the drawing step T is unchanged, the number of amplitude data of each waveform segment is unchanged, therefore, on the same device, whether the waveform graph is enlarged or reduced, the drawing performance will not be affected.
[0094] The third aspect of the present application provides an Android-based audio waveform graph drawing system, For an embodiment of the structure of the Android-based audio waveform graph drawing system 600, which is used for segmented drawing of the waveform graph, the system comprises:
[0095] The amplitude data acquisition module 601 is configured to acquire audio amplitude data;
[0096] The waveform graph pre-drawing module 602 is configured to segment the audio by length, each segment has a length of a screen width of the device, determine a segment currently swiped on the left side of the screen as a main segment, and draw a waveform graph of the main segment and several segments on the right side or on both sides of the main segment.
[0097] The swiping state monitoring module 603 is configured to monitor the swiping state of the waveform graph, and when the main segment changes, redraw the waveform graph of the current main segment and several segments on the left and right sides of the main segment.
[0098] The fourth aspect of the application provides an audio waveform graph zooming system based on Android, which comprises:
[0099] The waveform graph drawing module is configured to draw the waveform graph according to any method in the first aspect.
[0100] The zoom gesture monitoring module is configured to monitor the zoom gesture, record a zoom scale scale, and zoom the waveform graph according to the zoom scale scale.
[0101] The method for drawing and zooming the audio waveform graph on the Android device provided in the above embodiment uses the segmented processing method, and only needs to perform calculation and redrawing when the main segment is switched each time, so that the drawing efficiency of the waveform graph can be significantly improved. Meanwhile, only a small part of the waveform graph needs to be drawn each time, and compared with the method of drawing the entire waveform graph at one time, the OOM (out of memory) problem caused by insufficient memory of the device can be effectively avoided when a super-long waveform graph is processed.
[0102] Although the content of the application is specifically shown and introduced in combination with the preferred embodiments, those skilled in the art should understand that various changes can be made to the application in form and details without creative labor, as long as the changes do not deviate from the spirit and scope of the application defined in the appended claims, and the changes are within the protection scope of the application.
Claims
1. An Android-based audio waveform graph drawing method, characterized in that, The method comprises the steps of: acquiring audio amplitude data; segmenting the audio by length, each segment having a length of a screen width of the device, determining a segment currently swiped across a left side of the screen as a main segment, and drawing a waveform graph of a plurality of segments on a right side or both sides of the main segment, specifically comprising: calculating a number of amplitudes of the waveform graph to be drawn per screen width, pointPerScreen = screenWidth / T wherein, screenWidth is the screen width, and T is a drawing step length; calculating a current main segment index, currentIndex, currentIndex = scrollX / screenWidth wherein, scrollX is a horizontal scroll offset of a horizontal scroll container, screenWidth is the screen width; if the screen is swiped to the left, then the start index of drawing the waveform graph is currentIndex*pointPerScreen, and the end index of drawing the waveform graph is (currentIndex+n)*pointPerScreen, wherein n is a number of segments to be drawn each time; if the screen is swiped to the right, then the start index of drawing the waveform graph is (currentIndex-n1)*pointPerScreen, and the end index of drawing the waveform graph is (currentIndex+1+n2)*pointPerScreen, wherein n1 is a number of segments on a left side of the main segment, and n2 is a number of segments on a right side of the main segment; listening to a swiping state of the waveform graph, and redrawing the waveform graph of the current main segment and a plurality of segments on both sides of the main segment when the main segment changes. The method further comprises, if the waveform graph is swiped to the left, drawing an audio waveform graph of the main segment and at least two segments on a right side of the main segment; if the waveform graph is swiped to the right, drawing an audio waveform graph of the main segment and at least one segment on each of left and right sides of the main segment. 2.The Android-based audio waveform graph drawing method according to claim 1, characterized in that, The method further comprises, drawing a coordinate y-axis starting point as a height of a drawing view control, and drawing the waveform graph from a bottom of the control to the top. The method comprises the steps of: S21, drawing a waveform graph by using the method in any one of claims 1-3; 3.The Android-based audio waveform graph drawing method according to claim 1, wherein, S22, listening to a zoom gesture, recording a zoom scale scale, and zooming the waveform graph according to the zoom scale scale.
4. An Android-based audio waveform graph zooming method, characterized in that, The drawing step length T is changed according to the zoom scale scale. The drawing index increment is changed according to the zoom scale scale.
5. The Android-based audio waveform graph zooming method of claim 4, wherein, The method comprises: 6.The Android-based audio waveform graph zooming method according to claim 4, wherein, an amplitude data acquisition module configured to acquire audio amplitude data; 7. An Android-based audio waveform plotter system, comprising: a waveform graph pre-drawing module configured to segment the audio by length, each segment having a length of a screen width of the device, determine a segment currently swiped across a left side of the screen as a main segment, and draw a waveform graph of a plurality of segments on a right side or both sides of the main segment, specifically comprising: Calculate the number of points per screen, pointPerScreen = screenWidth / T Wherein, screenWidth is the screen width, T is the drawing step; Calculate the current main segment index currentIndex, currentIndex = scrollX / screenWidth Wherein, scrollX is the horizontal scroll offset of the horizontal scroll container, screenWidth is the screen width; If the screen is swiped to the left, Then draw the waveform graph startIndex = currentIndex*pointPerScreen endIndex = (currentIndex+n)*pointPerScreen Wherein, startIndex is the start index of the audio amplitude data to be drawn, endIndex is the end index of the audio amplitude data to be drawn, n is the number of segments drawn each time; If the screen is swiped to the right, Then draw the waveform graph startIndex = (currentIndex-n1)*pointPerScreen endIndex = (currentIndex+1+n2)*pointPerScreen 8. An Android-based audio waveform graph zooming system, characterized by, Wherein, n1 is the number of segments on the left of the main segment, n2 is the number of segments on the right of the main segment; Swipe state monitoring module, configured to monitor the swipe state of the waveform graph, and redraw the waveform graph of the current main segment and a plurality of segments on the left and right of the main segment when the main segment changes. Including:
9. A computer readable storage medium for Android-based audio waveform graphing or zooming, having stored thereon one or more computer programs, the computer program comprising: Waveform drawing module, configured to draw the waveform graph using the method of any one of claims 1-3; Zoom gesture monitoring module, configured to monitor the zoom gesture, record the zoom scale scale, and zoom the waveform graph according to the zoom scale scale. The one or more computer programs are executed by a computer processor to implement the method of any one of claims 1 to 6.
Citation Information
Patent Citations
Mass data graph drawing method and device
CN112256218A
Physiological oscillogram drawing method and device, computer equipment and readable storage medium
CN113129407A