Data access, sound mixing and power failure storage method for music circulation workstation
By simplifying the design method of sequential writing and data tables in music loop workstations, the problems of uncertain duration and insufficient RAM in data access and mixing of traditional file systems are solved, and more stable and efficient data management and audio processing effects are achieved.
Patent Information
- Application Number
- CN202411548004.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-25
AI Technical Summary
When the file system of traditional music loop workstations processes music data, frequent erasing, reading and writing operations lead to uncertain duration, increasing system overhead and delay. The MCU's RAM capacity is limited, making it difficult to accommodate large data tables, resulting in difficulty in finding and addressing data.
A method for data access, mixing and power-down storage of music loop workstations is proposed. By confirming the available space location of the NAND memory based on the power-down data at the initial power-up, load balancing and data reconstruction are realized; sequential writing is adopted to reduce system overhead and delay; the odd part of the data table is defined as the basic address and the even part is defined as the data length, and the indexing and management of large-capacity audio data is only required less than 1KB of RAM space.
It realizes a more stable and efficient data access and mixing process, reduces system overhead and latency, extends the service life of NAND memory, and solves the problem of insufficient MCU RAM resources.
Smart Images

Figure CN119512455A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of electronic audio processing, and in particular to a data access, mixing and power-off preservation method of a music circulation workstation. Background Art
[0002] Music loop workstations usually sample data during playing, and then save them as fragmented audio files according to a certain file system. When reading is needed, these files are read from various places for mixing calculations. These file systems are the basis for data access. Common file systems include: FAT / exFAT, YAFFS, UBIFS, JFFS2, littleFS, ext2 / 3 / 4. In embedded platforms with fewer resources, FATFS or littleFS are commonly used. Among them, due to the characteristics of NANDflash, it is particularly necessary to consider the design of the ftl layer for load balancing, bad block management, etc. The use of these file systems requires additional RAM space. This results in increased system overhead, complex functional design, reduced available resources and space, and higher latency.
[0003] Traditional file systems usually require frequent erase, read, and write operations when processing music data. The timing of these operations is uncertain and depends on the occupancy and remaining status of physical blocks, which may result in the need to move a large amount of data when writing a page, increasing the time consumption. In addition, in order to ensure the stable operation of the process, sufficient cache space is required, but this will lead to delay problems and affect the real-time nature of music creation. For music workstations, the RAM capacity of the MCU is limited, usually only tens to hundreds of KB, which is difficult to accommodate large data tables, resulting in difficulties in data search and addressing. At the same time, in order to achieve load balancing, ordinary file systems require additional cache space and complex algorithm design, which increases read and write time and system overhead. Therefore, we provide a method for data access, mixing, and power-off preservation for a music loop workstation. Summary of the invention
[0004] In view of the above-mentioned shortcomings of the prior art, the first purpose of the present invention is to provide a data access, mixing and power-off preservation method for a music circulation workstation to solve the problems in the above-mentioned background technology.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A method for data access, mixing and power-off saving of a music circulation workstation comprises the following steps:
[0007] S1, power-off data reconstruction;
[0008] S2, recording and playback;
[0009] S3. Establishment and updating of data tables based on the characteristics of the music loop workstation.
[0010] The present invention is further configured as follows: in the step S1, in power-off data reconstruction:
[0011] S1.1. When the power is first turned on, we need to confirm the next available space location of NAND based on the power-off data, so as to effectively achieve load balancing and extend the service life of the product;
[0012] S1.2, rebuild the previously recorded data table based on the power-off data. A large area is planned inside the MCU for data writing. The data can be written continuously according to the designed data structure based on the remaining space of the chip flash. The real-time data table and NAND write address and data length are written every time the recording is completed.
[0013] S1.3. According to the legality and specific value of the data length, decide whether to continue reading the data as the original information for reconstructing the data. When the data length is illegal, it means that the program has not been initialized or an error occurs. Erase all data and restore the first boot standby state. When the data length is 2, it means that there is no saved data. Just write the NAND address to restore it. According to the first boot standby, press the button to wait for the next state. When the data length is an even number between 2 and 258, we will rebuild the data table and restore the system state according to the recording and pause.
[0014] The present invention is further configured as follows: in the step S2 recording and playing:
[0015] S2.1. Write the audio data into NAND flash. Before writing, make sure that the storage block is erased.
[0016] S2.2, when it is necessary to read each previously recorded audio track, query the actual address where the corresponding data of each audio track at the corresponding time is stored through the corresponding data table, and then read the data of the calculated actual address;
[0017] S2.3. Multiply each read background audio track by the adjustment coefficient of the volume knob, and then add it to the real-time recorded audio to obtain the required superimposed audio track. This superimposed audio track will be used for playback, and if it is in recording at the time, this data will also be used to write storage.
[0018] The present invention is further configured as follows: in the step S3, in the establishment and update of the data table based on the characteristics of the music cycle workstation:
[0019] S3.1. Define the odd part of the data table as the basic address, and the even part as the data length starting from this address. In this way, a piece of data only needs 2 int type data, and only 8 bytes are needed in a 32-bit microcontroller to index a continuous audio data.
[0020] S3.2. After completing the first recording, the relative offset and write address of the loop period are given as parameters to the insertion algorithm when recording again. It is necessary to cleverly divide the data table of this initial section into two parts, and fill in the new write address and quantity from the insertion position. As the recording continues, the length of the original recording data will be shortened. Data is inserted according to the data insertion position required by the relative offset. Different algorithms will be used for insertion at different positions.
[0021] The present invention is further configured as follows: in the step S3, in the establishment and update of the data table based on the characteristics of the music loop workstation, the odd part of the data table is defined as the basic address, and the even part is defined as the data length starting from this address. If it is based on the establishment of a conventional data table, it is necessary to save the addresses of all pages in sequence, and the internal RAM space of a conventional MCU is far from enough.
[0022] The present invention is further configured as follows: in the step S2.3, after the data overflows, it can be restored to normal maximum and minimum clipping distortion. After the clipping is felt, the volume of the input sound source and background music can be appropriately adjusted, so that normal audio data can be obtained.
[0023] Beneficial Effects
[0024] Compared with the known public technology, the technical solution provided by the present invention has the following beneficial effects:
[0025] 1. Compared with the conventional file system, the duration of each erasing, reading and writing in the present invention becomes very uncertain, which depends entirely on the occupancy and remaining conditions of each physical block. When writing a page at a time, it may be necessary to move the data of 63 pages and erase the data of the original block at the same time. This will be very time-consuming and requires sufficient cache data to ensure that the process can run stably.
[0026] 2. Compared with conventional MCU, the RAM of the present invention is only between tens of KB and two or three hundred KB, which cannot even store our data table, so there is no way to search and address it. Based on the characteristics of the music loop workstation, the present invention innovatively proposes a method for establishing and updating a data table that only requires less than 1KB of RAM space.
[0027] 3. Compared with ordinary file systems, the present invention requires a lot of additional cache space, various overheads such as read and write time, and a complex load balancing algorithm to achieve load balancing. The sequential writing method of the present invention naturally achieves that the number of times each storage area is used is the same, and the consumption of all storage areas is completely balanced. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A schematic diagram of the data erasing and writing process of a data access and mixing method and a power-off preservation method for a music circulation workstation of the present invention;
[0029] Figure 2 A schematic diagram of a data reading flow of a data access and mixing and power-off preservation method of a music circulation workstation of the present invention;
[0030] Figure 3 A schematic diagram of a mixing calculation and anti-overflow design flow of a data access and mixing and power-off preservation method of a music circulation workstation of the present invention;
[0031] Figure 4 A schematic diagram of a data table establishment and update flow chart of a data access, mixing and power-off preservation method for a music circulation workstation of the present invention;
[0032] Figure 5 The present invention is a schematic diagram of the writing and reconstruction process of data that needs to be electrically preserved in a data access, mixing and power-off preservation method of a music circulation workstation. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0034] The present invention will be further described below in conjunction with the embodiments.
[0035] Example 1
[0036] like Figure 1-2 As shown, a method for data access, mixing and power-off preservation of a music loop workstation, step S1, power-off data reconstruction:
[0037] S1.1. When the power is first turned on, we need to confirm the next available space location of NAND based on the power-off data, so as to effectively achieve load balancing and extend the service life of the product;
[0038] S1.2, rebuild the previously recorded data table based on the power-off data. A large area is planned inside the MCU for data writing. The data can be written continuously according to the designed data structure based on the remaining space of the chip flash. The real-time data table and NAND write address and data length are written every time the recording is completed.
[0039] S1.3. According to the legality and specific value of the data length, decide whether to continue reading the data as the original information for reconstructing the data. When the data length is illegal, it means that the program has not been initialized or an error occurs. Erase all data and restore the first boot standby state. When the data length is 2, it means that there is no saved data. Just write the NAND address to restore it. According to the first boot standby, press the button to wait for the next state. When the data length is an even number between 2 and 258, we will rebuild the data table and restore the system state according to the recording and pause.
[0040] In the above embodiment, the available address of the NAND memory is obtained from the reconstruction data. When the system is powered on for the first time, the remaining available space location in the NAND memory needs to be confirmed based on the data at the time of power failure to ensure that subsequent data storage can be carried out reasonably, thereby achieving load balancing and extending the service life of the product. In the sequential writing mode, the load balancing problem can be naturally solved, because sequential writing ensures that the number of times each storage area is used is equal. In traditional file systems, in order to achieve load balancing, it is usually necessary to rely on additional cache space, complex read and write time management, and load balancing algorithms, all of which will bring additional resource consumption. Sequential writing avoids these complex designs. It fundamentally solves the problem of overuse of local areas by consuming each part of the storage area in a balanced manner, thereby extending the service life of the NAND memory.
[0041] When the device is powered on again, the system can rebuild the recorded data table based on the data before power failure, thus ensuring that key data such as recordings will not be lost. In order to avoid frequent erasing of NAND, reduce wear and tear caused by erase and write operations, and shorten the life of the device, the data writing area has been carefully planned, and a large area is divided inside the MCU to store recording data. The size of this area is flexibly adjusted according to the remaining flash space of the chip. The system has designed a continuous writing structure. At the end of each recording, the system will record the current data table, NAND write address and data length in real time. This operation ensures that even in the event of a sudden power failure, the recorded recording data and key information can be saved in time. When the user needs to delete a certain recording record, the system provides a simple operation method. By long pressing the button, the system will rewrite a set of data with a data length of 2. This design avoids tracing back to previously stored data segments, greatly simplifies the deletion operation, and ensures the integrity of the data storage structure.
[0042] The system uses a segmented reading method, similar to the logic of binary search, to find the end position of the stored data. When designing the data structure, the system ensures that the value of the data table, index address or data length cannot be 0xFFFFFFFF. When the device reads 0xFFFFFFFF, it means that no data has been written to the current reading area, which prompts the system to find the end of the stored data. The specific operation steps are: the system reads the end of each page in turn. If the end is detected to be 0xFFFFFFFF, it means that this is the last position of the data modification. Then, the system will read backward from the page until the first position that becomes 0xFFFFFFFF is found. The two values before this position represent the data length and the NAND write address respectively. By judging the legitimacy of the data length, the system can further decide whether to continue reading the data forward to rebuild the lost data table.
[0043] If the read data length is an illegal value, this usually indicates that the program has not been initialized or an error has occurred in the system. At this time, all data should be erased and the system should be restored to the standby state when it was first powered on. When the data length is 2, it means that no data is currently saved. The system only needs to restore the NAND write address and wait for the user to press the button to enter the next operation state according to the first power-on state. If the data length is a value between 2 and 258, it means that there is a recorded recording data segment. The system will rebuild the data table based on this and restore the device to the recording paused state. Through this design, the reconstruction process of power-off data can be completed quickly and efficiently.
[0044] Based on the conventional file system method, the duration of each erase, read, and write will become very uncertain. This depends entirely on the occupancy of each physical block, the remaining situation, etc. When writing a page at a time, we may need to move the data of 63 pages and erase the data of the original block at the same time, which will be very time-consuming. We will need enough cache data to ensure that this process can run stably. However, the delay problem caused by more cache is intolerable to musicians. For this reason, we have established an erase, read, calculate, and write process based on the characteristics of the music loop workstation. The erase and write process is relatively simple, such as Figure 1 When we are about to write a new block, we will erase the entire block. The writing is also done from small to large. The relatively complex part is the establishment and update of the data table. We will describe the establishment and update of the data table in detail in the next chapter. The reading process is also relatively simple, such as Figure 2When we need to read the previously recorded tracks, we can query the actual address of the corresponding data stored at the corresponding time of each track through the corresponding data table, and then read the data of the calculated actual address. The calculation process is not complicated. Figure 3 According to the design requirements of general music loop workstations, there is usually a background volume knob. We will multiply each read background track with the adjustment coefficient of the volume knob, and then add it to the real-time recorded audio to get the superimposed track we need. We will use this superimposed track for playback, and if it is in the process of recording, we will also use this data for writing to storage. It should be noted that after multi-track audio is superimposed on each other, it is very likely to cause audio distortion. Therefore, in addition to the musicians trying to control the normal volume below -12dB when recording, we must also avoid the error of data overflowing the maximum and minimum values during the calculation process.
[0045] Example 2
[0046] like Figure 1-3 As shown, a method for data access, mixing and power-off preservation of a music loop workstation, step S2 recording and playing:
[0047] S2.1. Write the audio data into NAND flash. Before writing, make sure that the storage block is erased.
[0048] S2.2, when it is necessary to read each previously recorded audio track, query the actual address where the corresponding data of each audio track at the corresponding time is stored through the corresponding data table, and then read the data of the calculated actual address;
[0049] S2.3. Multiply each background audio track read by the adjustment coefficient of the volume knob, and then add it to the real-time recorded audio to obtain the required superimposed audio track. This superimposed audio track will be used for playback, and if it is in recording at the time, this data will also be used to write to the storage;
[0050] In step S2.3, after the data overflows, it can be restored to the normal maximum and minimum clipping distortion. After feeling the clipping, the volume of the input sound source and background music can be appropriately adjusted, so that normal audio data can be obtained.
[0051] In the above embodiment, the core operation of recording is to write the audio data into NAND Flash. Before performing the write operation, it is necessary to ensure that the storage block has been erased. The specific operation steps are as follows: Figure 1As shown in the figure: When the system is about to write a new block, it first performs a global erase on the entire block to ensure that the data in the storage block is clean. Subsequently, the recording data will be written to the block in sequence. This sequential writing method not only ensures the integrity of the data, but also improves the efficiency of data storage.
[0052] During the recording data writing process, the data of each audio track will be recorded in the order of the recording time and stored in a specific NAND Flash address. This process is not just a simple audio storage, but also requires the system to generate a corresponding index for each recording so that the corresponding audio data can be quickly found when playing or superimposing in the future. At the same time, in order to avoid frequent erase and write operations on NAND Flash, the recording data is generally stored in the same storage block in sequence, and the next round of erase and write operations will be performed when the storage block is almost full. This method can effectively extend the service life of the memory.
[0053] The core operation of playback is to read the recorded audio data according to the cycle, and after superimposing and calculating with the real-time music, play it out from the output port. During playback, the system will first query the data storage location of the time slice corresponding to each track through the data table. According to the time index of the recording, the system can find the data address corresponding to each track in different time periods, and then the system reads the audio data from these calculated actual addresses for playback. In this process, the system needs to determine in real time whether the recording time period exceeds the current cycle. If the recording has exceeded the current cycle, it is necessary to read the audio data from the storage address before the previous cycle, so as to ensure that the multiple superimposed audio tracks recorded can be read and played continuously.
[0054] A key technical difficulty in playback is how to adjust the background volume when tracks are superimposed and prevent audio data overflow. In the process of superimposition calculation, background volume adjustment and overflow control are both important parts. Figure 3 As shown, there is usually a background volume knob in the design of a music workstation. When the system reads each track, it adjusts the background volume of each track according to the volume knob adjustment coefficient set by the user. By multiplying the read background track data by the corresponding adjustment coefficient and adding it to the real-time recorded audio, the system generates the superimposed audio tracks to be played. These tracks are not only used for real-time playback, but also rewritten to the storage device during the recording process.
[0055] In the process of multi-track audio superposition, the problem of audio data overflow is particularly prone to occur. When the volume values of multiple audio tracks are accumulated, they may exceed the maximum or minimum value of the audio data, resulting in distortion noise, which seriously affects the playback effect. In order to deal with this situation, the system has designed a numerical scaling mechanism. When audio data overflow is detected, the system will limit its value to the allowed range and perform clipping distortion processing. Clipping distortion means that when the audio data exceeds the maximum or minimum threshold, the system will cut it to the maximum or minimum value to avoid greater distortion. Although this design will cause some loss in sound quality, it can avoid severe noise in extreme cases and maintain the overall quality of audio playback.
[0056] For example, when a musician feels clipping distortion during a performance, the playback effect can be optimized by adjusting the input sound source and background volume. By appropriately reducing the volume of the input signal or lowering the volume of the background music, the system can avoid the overflow problem after multi-track audio is superimposed, thereby ensuring the stability of the quality of the played audio data. In addition, the clipping distortion mechanism also has a certain automatic adjustment function, which can actively intervene when data overflows, helping users maintain the stability of audio output and reducing the complexity of manual adjustment.
[0057] The design of the recording and playback system is achieved through multi-level technology to ensure the stability of recording, the real-time playback, and the quality control of audio superposition. From the erasure management of recording data, the real-time calculation of track superposition, to the adjustment of background volume and overflow control, each link has been carefully designed to ensure that the system can operate efficiently in complex music performance and recording scenarios. This design not only improves the user experience, but also improves the overall performance and reliability of the device. In multi-track recording and superposition playback, the system can respond to changes quickly and ensure the normal output of audio data through the built-in anti-overflow mechanism, making the entire recording and playback process smooth and natural, with clear and stable sound quality.
[0058] Based on the considerations of establishing a conventional data table, we need to save the addresses of all pages in sequence. Take the storage chip MX35LF2GE4AD as an example. This is a 2Gb SPI NAND Flash chip. 1 chip = 2048 blocks; 1 block = 64 pages; 1 page = 2048 bytes. Then its addressing range is 0 to 0x20000, which just exceeds the 16-bit addressing range. If stored in 32 bits, the space required to store the data sequence table is 512KB. However, our conventional MCU has a RAM of only tens of KB to two or three hundred KB, which can't even store our data table, so there is no way to find the address. Based on the characteristics of the music loop workstation, we innovatively proposed a method for establishing and updating a data table that only requires less than 1KB of RAM space, such as Figure 4Based on the continuous writing characteristics of the music workstation, we define the odd part of the data table as the basic address, and the even part as the data length starting from this address. In this way, a segment of data only needs 2 int type data, and only 8 bytes are needed in a 32-bit microcontroller to index a segment of continuous audio data. When it is necessary to enter the superposition midway, the data table of the initial segment is cleverly divided into two, and the new write address is filled in from the insertion point. In this way, after the second segment of data is superimposed, this data only occupies 2 ints, which are divided into two and become 4 ints. A new 2 ints are added, so there are 6 int data in total. Only 4 ints are added, which means one more superposition. According to the worst superposition, 1KB can store 256 ints, which can store 64 fragmented audio clips. In fact, in the use of the music loop workstation, the user's loop cycle is generally no more than 4 eight beats or 8 eight beats, which is only a few seconds or more than ten or twenty seconds of audio data. Multi-segment superposition is also mostly within ten times. Even if it is superimposed multiple times, if the next recording is a little longer, it will include the previous fragmented audio, thus shortening the data table. For this purpose, we have designed a set of data table creation and update algorithms. When we read, we can also use this algorithm to obtain the corresponding page address.
[0059] Example 3
[0060] like Figure 1-5 As shown, a method for data access, mixing and power-off preservation of a music loop workstation, step S3, establishing and updating a data table based on the characteristics of the music loop workstation:
[0061] S3.1. Define the odd part of the data table as the basic address, and the even part as the data length starting from this address. In this way, a piece of data only needs 2 int type data, and only 8 bytes are needed in a 32-bit microcontroller to index a continuous audio data.
[0062] S3.2. After the first recording is completed, the relative offset and write address of the cycle are given as parameters to the insertion algorithm when recording again. It is necessary to cleverly divide the data table of the initial section into two parts, and fill in the new write address and quantity from the insertion position. As the recording continues, the length of the original recording data will be shortened. Data is inserted according to the data insertion position required by the relative offset. Different insertion positions will have different algorithms;
[0063] Step S3, in the establishment and update of the data table based on the characteristics of the music loop workstation, the odd part of the data table is defined as the basic address, and the even part is defined as the data length starting from this address. If it is based on the establishment of a conventional data table, it is necessary to save the addresses of all pages in sequence, and the internal RAM space of a conventional MCU is far from enough.
[0064] In the above embodiment, the odd-numbered part of the data table is defined as the base address, and the even-numbered part is defined as the data length starting from the base address. Such a design simplifies the structure of the data table, so that each segment of data only needs two integer values to complete the index. In a 32-bit MCU system, this means that each continuous audio data only needs 8 bytes to complete the storage and positioning. Such a storage method saves space and ensures the continuity and integrity of the audio data.
[0065] During the first recording, the system will predetermine the entire cycle and the base address and data length of the data within the cycle. During each recording process, the audio data will be written to the Flash storage in sequence according to the cycle. In this way, the establishment of the data table can not only effectively reduce the RAM usage, but also ensure the sequential writing and convenient management of the recording data.
[0066] After the first recording is completed, the existing data table will be updated with subsequent recording data. The update process involves inputting the new recording data into an insertion algorithm according to the relative offset and write address of the cycle as parameters. The key to the update is how to cleverly split the data table generated by the initial recording and fill in the new write address and data length at the appropriate insertion position.
[0067] When a new recording is made, the system needs to adjust the existing data table according to the time point of the recording. Since the new recording may occur at any position, the position of the insertion operation also needs to be determined according to the relative offset of the recording. After inserting the new data, the length of the original recording data will be shortened accordingly, ensuring that both new and old recording data can be correctly recorded and managed. The insertion operation is not limited to a specific position, but is flexibly adjusted according to the time point of the recording. As the recording continues, subsequent recording data will continue to be inserted into the appropriate position, and different insertion positions may trigger different update algorithms.
[0068] This data insertion method based on relative offset enables the system to efficiently handle multiple recordings and data updates. Whether it is the data table generated by the first recording or the data table updated later, the system can quickly respond to changes in recording data and ensure data integrity and availability through a flexible insertion algorithm. This method greatly reduces RAM usage and enables the system to smoothly handle large-capacity data management issues.
[0069] Based on the characteristics of the music loop workstation, this innovative data table creation and update method solves the problem of insufficient MCU RAM resources through clever design. It only requires less than 1KB of RAM space to achieve efficient management of a large amount of recording data in NAND Flash. By using the odd part of the data table as the base address and the even part as the data length, the system greatly simplifies the structure of the data table, making data storage and search more lightweight.
[0070] Power-off saving is a function that musicians will use when they have a good basic idea when using the music loop workstation to create. They will make multiple attempts based on the same background music until they are satisfied. This time span may be long. If the audio needs to be imported and exported every time it is used, or even lost when the power is off, it is definitely unacceptable. Therefore, we have designed a convenient power-off saving implementation method based on the music loop workstation. This method mainly includes the writing and reconstruction of data that needs to be saved after power failure, such as Figure 5 , data writing is to directly write the latest write address of NAND Flash, the current data table, and the length of the entire data to the unused flash area of dozens of KB at the end of the MCU. This size can be adjusted according to the number of times it is used. Rolling address writing can effectively improve the service life of Flash and avoid frequent erasing. When the remaining area of MCU may not be able to store a data table once, we will completely erase this part and then write it again from the beginning. Data reconstruction is to first obtain the non-0xFF information at the end of the MCU, which is the stored data length, and then read an int data forward, which is the latest write address of the stored NANDFlash. We perform a certain legality check on this part of data. After confirming that the data is valid, we decide whether to read the data table written to the MCU again based on the data length. If the data length is 2, it means that there are only two int data in the data, namely the latest write address of NAND Flash and the data length itself, and there is no need to rebuild the data. If the data is greater than 2 and is an even number and less than a certain value (this specific value is taken as the maximum number of superposition segments × 4 + 2), then read so many int data, which are all the data tables we saved before. We restore the state bits, arrays, etc. related to the running loop to the extracted values to achieve data reconstruction.
[0071] In the present invention, when the system is powered on for the first time, it will first confirm the available space position of the NAND memory based on the data before power failure, to ensure that subsequent data storage can achieve load balancing and extend the service life of the NAND. This step ensures that each storage area is used the same number of times by sequential writing, avoids excessive use of local areas, and improves the overall stability of the system. When the device is powered on again, the system will rebuild the recording data according to the data table before power failure. To this end, the system has planned a large area inside the MCU for continuously writing key information such as the recording data table, NAND write address and data length to avoid data loss. When reading the stored data, the system will find the end position of the data through the segmented reading method, and perform corresponding reconstruction operations according to the legitimacy of the data length to ensure the integrity and accuracy of the data table.
[0072] The core operation of recording is to write audio data into NAND Flash. Before writing, it is necessary to ensure that the target storage block has been erased. The system will write the recording data in sequence and generate corresponding indexes to facilitate subsequent searches. During playback, the system will query the data table to obtain the actual storage address of each track, read out the data of the corresponding time slice, and play it. A key link in audio playback is to superimpose different tracks and adjust the background volume. The system uses the volume knob adjustment coefficient set by the user to superimpose the read track with the real-time recording to generate the final playback track. These tracks are not only used for playback, but also rewritten to NAND storage. In the process of multi-track audio superposition, the system adopts a clipping distortion processing mechanism to prevent audio data overflow and maintain the stability of audio quality.
[0073] In the data management based on the characteristics of the music loop workstation, the system adopts an innovative way to establish and update the data table. The system defines the odd part of the data table as the basic address, and the even part as the data length starting from this address. This simplified data table structure only requires less than 1KB of RAM space to complete the indexing and management of large-capacity audio data. After the recording is completed, the system will update the data table through the relative offset and write address. When new recording data is inserted, the system will adjust the data table according to the relative offset of the recording to ensure that the new and old data are fully recorded. This update process effectively reduces the RAM usage through a flexible insertion algorithm, while improving the system's management efficiency and recording processing capabilities.
[0074] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for data access, mixing and power-off preservation of a music circulation workstation, characterized in that: The following steps are involved: S1, power-off data reconstruction; S2, recording and playback; S3. Establishment and updating of data tables based on the characteristics of the music loop workstation.
2. The data access, mixing and power-off preservation method of a music circulation workstation according to claim 1, characterized in that: In the step S1, power-off data reconstruction: S1.
1. When the power is first turned on, we need to confirm the next available space location of NAND based on the power-off data, so as to effectively achieve load balancing and extend the service life of the product; S1.2, rebuild the previously recorded data table based on the power-off data. A large area is planned inside the MCU for data writing. The data can be written continuously according to the designed data structure based on the remaining space of the chip flash. The real-time data table and NAND write address and data length are written every time the recording is completed. S1.
3. According to the legality and specific value of the data length, decide whether to continue reading the data as the original information for reconstructing the data. When the data length is illegal, it means that the program has not been initialized or an error occurs. Erase all data and restore the first boot standby state. When the data length is 2, it means that there is no saved data. Just write the NAND address to restore it. According to the first boot standby, press the button to wait for the next state. When the data length is an even number between 2 and 258, we will rebuild the data table and restore the system state according to the recording and pause.
3. The data access, mixing and power-off preservation method of a music circulation workstation according to claim 1, characterized in that: In the step S2 recording and playing: S2.
1. Write the audio data into NAND flash. Before writing, make sure that the storage block is erased. S2.2, when it is necessary to read each previously recorded audio track, query the actual address where the corresponding data of each audio track at the corresponding time is stored through the corresponding data table, and then read the data of the calculated actual address; S2.
3. Multiply each read background audio track by the adjustment coefficient of the volume knob, and then add it to the real-time recorded audio to obtain the required superimposed audio track. This superimposed audio track will be used for playback, and if it is in recording at the time, this data will also be used to write storage.
4. The data access, mixing and power-off preservation method of a music circulation workstation according to claim 1, characterized in that: In the step S3, establishing and updating the data table based on the characteristics of the music loop workstation: S3.
1. Define the odd part of the data table as the basic address, and the even part as the data length starting from this address. In this way, a piece of data only needs 2 int type data, and only 8 bytes are needed in a 32-bit microcontroller to index a continuous audio data. S3.
2. After completing the first recording, the relative offset and write address of the loop period are given as parameters to the insertion algorithm when recording again. It is necessary to cleverly divide the data table of this initial section into two parts, and fill in the new write address and quantity from the insertion position. As the recording continues, the length of the original recording data will be shortened. Data is inserted according to the data insertion position required by the relative offset. Different algorithms will be used for insertion at different positions.
5. The data access, mixing and power-off preservation method of a music circulation workstation according to claim 1, characterized in that: In the step S3, in the establishment and update of the data table based on the characteristics of the music loop workstation, the odd part of the data table is defined as the basic address, and the even part is defined as the data length starting from this address. If it is based on the establishment of a conventional data table, it is necessary to save the addresses of all pages in sequence, and the internal RAM space of a conventional MCU is far from enough.
6. The data access, mixing and power-off preservation method of a music circulation workstation according to claim 3, characterized in that: In step S2.3, after the data overflows, it can be restored to normal maximum and minimum clipping distortion. After feeling the clipping, the volume of the input sound source and background music can be appropriately adjusted, so that normal audio data can be obtained.