A method for converting musical melody by drawing curves

By drawing curves and rasterizing images in LabVIEW, the problems of large data volume and low processing efficiency in the existing technology are solved, the efficient generation and storage of music melodies is achieved, and the fun of packaging products and children's music creation are improved. potential.

CN111862269BActive Publication Date: 2024-08-23JINAN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010729190.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-27
Publication Date
2024-08-23
Estimated Expiration
2040-07-27

AI Technical Summary

Technical Problem

In the existing technology, the method of drawing curves to convert music melody has problems such as large data volume, low processing efficiency and poor interactivity, which results in the lack of interest in packaged products, especially the lack of effective music creation inspiration in children's books.

Method used

By drawing curves in LabVIEW, rasterizing the image, compressing the processed image data, converting it into note and pitch information, generating a musical melody, and saving and playing it in the form of a MIDI file.

Benefits of technology

It improves the interactivity and reading experience of packaging products. The generated music melody combines graphics, text and sound, and enhances the potential of children's music creation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111862269B
    Figure CN111862269B
Patent Text Reader

Abstract

The present invention discloses a method for converting a curve into a music melody, comprising the following steps: step 1, drawing a curve and converting it into an image; step 2, rasterizing the acquired curve image; step 3, outputting the rasterized curve image; step 4, generating a music melody of the drawing curve; step 5, saving the generated melody information in the form of a MIDI file. The method of the present invention obtains an image from a storage device for any drawn curve, the value of the number of pixels of the digital image is much larger than the number of elements in the pitch array, rasterizes the digital image, compresses the image data during output, and reduces the amount of processed data. The rasterized image is converted into the note and pitch information in the music melody to generate a music melody.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of information technology in printing application technology, and in particular to a method for converting a drawing curve into a music melody. Background Art

[0002] With the popularization of Internet and mobile phone users, the demand for paper media to improve the interactivity and fun of paper packaging and printing products is increasing. Based on the commonly used LabVIEW, a curve is randomly drawn, and the curve is imported into the computer for raster processing and output, and converted into a musical melody to achieve the effect of combining pictures, texts and sounds, improve the fun of packaging and printing products, and be applied to packaging and printing products, especially children's books, which can inspire the potential of children's music creation.

[0003] In the prior art, the technical solution with application number 201410135119.X and patent application name “A method for generating music melody in the form of line drawing” completes the conversion of music melody through the grayscale histogram method. Summary of the invention

[0004] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and provide a method for converting a drawn curve into a musical melody. The method obtains an image from a storage device for any drawn curve. The value of the number of pixels in the digital image is much larger than the number of elements in the pitch array. The digital image is rasterized and the image data is compressed during output to reduce the amount of data processed. The rasterized image is converted into the note and pitch information in the musical melody to generate a musical melody. The method solves the problem of poor interactivity of existing packaging products and improves the reader's experience.

[0005] The purpose of the present invention is achieved through the following technical solutions:

[0006] A method for converting a musical melody by drawing a curve comprises the following steps:

[0007] Step 1, draw the curve and convert it into an image;

[0008] Step 2, rasterizing the acquired curve image;

[0009] Step 3, outputting the rasterized curve image;

[0010] Step 4, draw the generation of the curve music melody;

[0011] Step 5, saving the generated melody information in the form of a MIDI file.

[0012] The step 1 is specifically as follows: drawing a curve of any shape on paper and taking a photo to obtain a curve image, and then appropriately cropping the curve image.

[0013] The step 1 is specifically as follows: drawing a curve in the LabVIEW program; writing a vi for drawing an image in LabVIEW; in the process of drawing the curve vi in ​​LabVIEW, the event structure includes four events: timeout, drawing, redrawing, and stopping; the drawing, resetting, and image output of the curve are completed through the code in the event structure; the image data of the output while loop is transmitted to the next level of processing vi through the attribute node; the image is drawn by recording the coordinates of the mouse movement, and the recorded coordinates are transmitted in the form of a two-dimensional array.

[0014] The step 2 is specifically as follows: by setting the rasterization specification r to 4 to 16, the acquired grayscale image is rasterized, a column of pixels is selected with the specification r, the selected column of pixels is divided into r rows, the pixel values ​​of each row are summed, and finally the index number of the smallest column is output, which is used as the index value; the above-mentioned processing is performed on the image in a loop to finally obtain a processed rasterized image; the input image is processed to obtain a r×r grid image with pixels.

[0015] The step 3 is specifically as follows: calling the sub-vi through the top-level vi to complete image acquisition, processing, and conversion; processing the output image through the rasterization vi, and outputting an array representing the melody line; setting the timeout to 5-10 seconds in the image processing program box, drawing, and importing pictures; when running the program, triggering after completing the drawing operation or reading the image operation, processing the input image data and inputting it into the melody generation vi.

[0016] The step 4 is specifically as follows: generating a music melody by indexing the frequency value of the pitch array: importing a digital image file in the format of jpg, png, or bitmap for processing; triggering an import picture event to complete the import and acquisition of a target digital image; setting the frequencies of 4 to 8 notes, selecting a major scale, and selecting index values ​​of 0 to 7; the method of generating an index value array is shown in formula (1), and a new array is generated by the frequency generated by the index value, and the array constitutes a melody line;

[0017] B i =(S-1)·A i / A max (1)

[0018] Where:

[0019] B——the i-th element in the array Array;

[0020] S——the size of the array that makes up the notes;

[0021] A i ——The i-th element in the array Array;

[0022] A max ——The maximum value in the array Array;

[0023] The generation of the music melody is completed by the melody generation vi; the array output in the previous level vi is processed according to formula (1), the elements of the array are converted into index values ​​to index the frequency array, and it is played through beep.vi, and a new array composed of the indexed frequency values ​​and the generated number are output at the same time.

[0024] The step 5 is specifically as follows: set the tempo Bpm to 60-140; the number of ticks of a note with a duration of one beat is 80-140; set the timbre to 0-7 and convert the decimal value to hexadecimal through the type conversion control in the program; create a MIDI file to generate vi, and record the generated music melody in the form of a MIDI file for later viewing and editing; in order to realize the generation of event information in the MIDI file, it is necessary to input the pitch number in the track block, and convert the frequency value in the new array with the order of pitch appearance generated by the digital image into the pitch number in the MIDI file; converting the generated music melody into a MIDI file requires converting the frequency value in the new array into the pitch number in the MIDI file, and converting the frequency into the pitch number Ii. The solution formula for Ii is as follows:

[0025] I i =log 1.05964 (B i / 16.345) (2)

[0026] Where:

[0027] Bi——the i-th element in the new array, the value of each element is the value of the frequency;

[0028] Ii——The pitch number corresponding to the i-th note in the MIDI file;

[0029] The generated melody information is saved in the form of MIDI file and can be played directly.

[0030] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0031] The present invention draws a curve in a certain way, rasterizes an image through LabVIEW, outputs the rasterized image, generates a music melody, and stores and plays it in the form of a MIDI file. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is the flowchart of the drawing vi program;

[0033] Figure 2It is to draw the image rasterization process flow chart;

[0034] Figure 3 It is the rasterized image output and melody generation diagram;

[0035] Figure 4 is an arbitrarily drawn curve;

[0036] Figure 5 It is a rasterized image.

[0037] Figure 6 is the transformed image;

[0038] Figure 7 is the generated five-line staff. DETAILED DESCRIPTION

[0039] The present invention is further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.

[0040] Embodiment 1

[0041] A method for converting a musical melody by drawing a curve comprises the following steps:

[0042] Step 1, draw the curve and convert it into an image:

[0043] Complete the drawing of the curve in the LabVIEW program, write the vi for drawing images in LabVIEW, and complete the function of drawing curves on the computer to obtain the melody line. Specifically, in the process of drawing the curve vi in ​​LabVIEW, through the while loop, the event structure includes four events: timeout, drawing, redrawing, and stop. The code in the event structure completes the drawing, resetting, and image output of the curve. The image data output from the while loop is passed to the next level of processing vi through the attribute node. The image is drawn by recording the coordinates of the mouse movement, and the recorded coordinates are passed in the form of a two-dimensional array. Figure 1 shown.

[0044] Step 2: rasterize the acquired image information:

[0045] The obtained grayscale image is rasterized by setting the rasterization specification r to 4-16, selecting a column of pixels with the specification of r(4-16)), dividing the selected column of pixels into r(4-16) rows, summing the pixel values ​​of each row, and finally outputting the index number of the smallest column as the index value. The above process is repeated for the image, and finally the processed rasterized image is obtained. The program flow is as follows: Figure 2 As shown in , the input image can be processed to obtain a r×r grid image. Figure 2 shown.

[0046] Step 3, output of rasterized image

[0047] The top-level vi calls the sub-vi to complete image acquisition, processing, and conversion. The flowchart of the program for converting music melody through curves is as follows Figure 3 As shown, the output image is processed by rasterization vi, and an array representing the melody line is output. In the image processing program box, the timeout is set to 5-10 seconds, drawing, and importing pictures. When the program is run, it is triggered after the drawing operation or the image reading operation is completed. The input image data is processed and input into the melody generation vi.

[0048] Step 4 is specifically as follows: generating a curve music melody;

[0049] Import pictures, digital image files in jpg, png, bitmap format for processing. Run the program, such as Figure 4 Click the Import Picture button shown in the figure to trigger the Import Picture event. Select the picture to be processed to complete the import and acquisition of the target digital image. Set the frequencies of 4-8 notes, select a major scale, and select index values ​​from 0 to 7. The method of generating an index value array is shown in formula (1). The frequency generated by the index value generates a new array. This array constitutes a melody line. The generation of the music melody is completed by the melody generation vi. According to formula (1), the array output in the previous level vi is processed, and the elements of the array are converted into index values ​​to index the frequency array. It is played through beep.vi, and the new array composed of the indexed frequency values ​​and the generated number are output at the same time. As shown Figure 3 shown.

[0050] Step 5 is as follows: Generation of MIDI files

[0051] Set the tempo Bpm to 60-140; the number of ticks per beat to 80-140; set the timbre to 0-7. Use the type conversion control in the program to convert the decimal value to hexadecimal. Create a MIDI file generation vi and record the generated music melody in the form of a MIDI file for later viewing and editing. In order to generate event information in the MIDI file, it is necessary to input the pitch number in the track block and convert the frequency value in the new array with the order of pitch appearance generated by the digital image into the pitch number in the MIDI file. Converting the generated music melody into a MIDI file requires converting the frequency value in the new array into the pitch number in the MIDI file, and converting the frequency into the pitch number.

[0052] Embodiment 2

[0053] The production and operation process of the present invention is now described by taking the example of randomly drawing a picture to generate a musical melody.

[0054] (1) Draw a curve and convert it into an image: Draw a curve of any shape on paper and import it into a computer by taking a photo with a mobile phone. Use a mobile phone or camera to take a photo under fluorescent light with a shooting accuracy of 300-600 DPI. Use PS software on the computer to cut it into a size of 70-100 mm in length;

[0055] Cut A4 paper into square pieces with a side length of 8.5 mm, draw with a marker, use a Huawei phone to take photos under room light, import the photos into the computer, and use Photoshop to process the edges. Figure 4 shown.

[0056] Step 2: rasterize the acquired image information.

[0057] Set the rasterization specification to 8, set the timbre in the MIDI generation parameters to 0, the volume to 80, the bpm to 120, and the scale used to generate the music melody to the natural scale. Figure 5 shown.

[0058] Step 3: Output of rasterized image

[0059] In the image processing program box, set the timeout to 5-10 seconds, draw, and import pictures. When the program is running, it is triggered after the drawing operation or image reading operation is completed. The input image data is processed and input into the melody generation vi. The rasterized output image is as follows Figure 6 shown.

[0060] Step 4 is specifically as follows: generating a curve music melody;

[0061] Import the image in bitmap format and run the program, such as Figure 3 The Import Picture button shown triggers the Import Picture event. Select the picture to be processed to complete the import and acquisition of the target digital image. Figure 3 Run the program as shown, set the frequencies of 7 notes. Select the C major scale frequency, the index values ​​are arranged from 0 to 7, and establish the C major scale to generate a music melody by indexing the pitch frequency values. The scale used to generate the music melody is set to the natural scale. Figure 7 shown.

[0062] (5) Generate MIDI file for playback:

[0063] When the MIDI parameters are set to 0 for the timbre and 120 for the volume at 80Bpm, the number of ticks for a beat is 120, which is 78 in hexadecimal. The number of ticks for a half beat is 60, which is 3C in hexadecimal. The data types of the volume and timbre values ​​need to be converted to 8 bits, and the MIDI files are generated for piano timbres from 0 to 7.

[0064] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A method for converting a musical melody by drawing a curve, characterized in that: The following steps are involved: Step 1, draw the curve and convert it into an image; Step 2, rasterizing the acquired curve image; By setting the rasterization specification r to 4 to 16, the obtained grayscale image is rasterized, a column of pixels is selected with the specification r, the selected column of pixels is divided into r rows, the pixel values ​​of each row are summed, and finally the index number of the smallest column is output and used as the index value; the image is rasterized in a loop to obtain a processed rasterized image; the input image is processed to obtain a r×r raster image; Step 3, outputting the rasterized curve image; The step 3 is specifically as follows: calling the sub-vi through the top-level vi to complete image acquisition, processing, and conversion; processing the output image through the rasterization vi, and outputting an array representing the melody line; setting the timeout to 5-10 seconds in the image processing program box, drawing, and importing pictures; triggering the image processing program after completing the drawing operation or the image reading operation, processing the input image data, and then inputting it into the melody generation vi; Step 4, draw the generation of the curve music melody; Step 5, saving the generated melody information in the form of a MIDI file; The step 5 is specifically as follows: setting the tempo Bpm to 60-140; the number of ticks of a note with a duration of one beat to 80-140; setting the timbre to 0-7 and converting the decimal value to hexadecimal through a type conversion control in the program; establishing a MIDI file to generate vi, and recording the generated music melody in the form of a MIDI file for later viewing and editing; in order to realize the generation of event information in the MIDI file, it is necessary to input the pitch sequence number in the track block, and convert the frequency value in the new array with the pitch appearance order generated by the digital image into the pitch sequence number Ii in the MIDI file; and saving the generated melody information in the form of a MIDI file, which can be played directly.

2. The method for converting a musical melody by drawing a curve according to claim 1, characterized in that: The step 1 is specifically as follows: drawing a curve of any shape on paper and taking a photo to obtain a curve image, and then appropriately cropping the curve image.

3. The method for converting a musical melody by drawing a curve according to claim 1, characterized in that: The step 1 is specifically as follows: drawing a curve in the LabVIEW program; writing a vi for drawing an image in LabVIEW; in the process of drawing the curve vi in ​​LabVIEW, the event structure includes four events: timeout, drawing, redrawing, and stopping; the drawing, resetting, and image output of the curve are completed through the code in the event structure; the image data of the output while loop is transmitted to the next level of processing vi through the attribute node; the image is drawn by recording the coordinates of the mouse movement, and the recorded coordinates are transmitted in the form of a two-dimensional array.

4. The method for converting a musical melody by drawing a curve according to claim 1, characterized in that: The step 4 is specifically: generating a music melody by indexing the frequency value of the pitch array: Import digital image files in the format of jpg, png, or bitmap; trigger the import image event to complete the import and acquisition of the target digital image; set the frequencies of 4 to 8 notes, select a major scale, and select index values ​​from 0 to 7; the method for generating an index value array is shown in formula (1), and a new array is generated by the frequency generated by the index value, which constitutes a melody line; B i =(S-1)·A i / A max (1) Where: B i ——The i-th element in the new array Array; S——the size of the array that makes up the notes; A i ——The i-th element in the array Array; A max ——The maximum value in the array Array; The generation of the music melody is completed by the melody generation vi; the array output in the previous level vi is processed according to formula (1), the elements of the array are converted into index values ​​to index the frequency array, and it is played through beep.vi, and a new array composed of the indexed frequency values ​​and the generated number are output at the same time.

5. The method for converting a musical melody by drawing a curve according to claim 4, characterized in that: The solution formula for Ii is as follows: I i =log 1.05964 (B i / 16.345) (2) Where: B i ——The value of the i-th element in the new array Array is the value of the frequency; I i ——The pitch number corresponding to the i-th note in the MIDI file.