I used to enjoy classical music is listening to the CD, so the collection of a lot of CDs and downloaded to the computer Ape and FLAC format music files. As mobile hardware performance (such as battery life, processor speed, sound quality, storage capacity, etc.) and software features (music player management for tracks) improve, you need to consider how to convert these resources into high-quality MP3 files to listen on your phone. This article describes how to implement this functionality based on Audacity, K3B, Easytag software, and the bash scripts that you write on Gnu/linux.
Grab music from disc and switch to MP3
K3B is the default CD burning and gripping software in the KDE environment. Its interface is as shown.
Select Rip Audio CD in menu tools, which we can use to grab and remove WAV files directly from the CD. Next, open the Audacity music editing software and import (rather than open) multiple WAV files into multiple audio tracks. Then select Export multiple in the files, choose the export format as MP3, the sample frequency in the export option is set to +/-Kbps, and click Export to complete the conversion. As shown in.
Finally, open the Easytag software and fill in the MP3 file's track information (ID3 Tag). Note that you can apply settings to all selected files at once by tapping the dots next to the info text box. As shown in.
Convert ape or FLAC files to MP3 file
Generally downloaded CD RIP files are in ape or FLAC format and have lossless sound quality. Can be directly copied to the phone, one is that some software may not support the two formats, the second is that they occupy too large storage space, third, because they also do not contain similar to the MP3 file ID3 tag information, so that the music playback software automatically according to the album name or composer name and automatically classified management. Therefore, it is necessary to split the ape and FLAC files into MP3 format, fill in the track information and then import the phone.
As can be seen here, the first thing to solve is the ape and FLAC file splitting problem. In general, a file with the extension cue will also be downloaded with them. This file holds the track information for the CD, including the music style (GENRE), Year of production (DATE), performer (performer), album/CD name (title), ape or FLAC file name (file), and the title (title), performer (performer), and start time (INDEX 01) for each track. As shown below:
rem GENRE classical
rem DATE 1991
Rem discid 9b0e701c
rem COMMENT "exactaudiocopy v0.95b4"
P Erformer "Wächter, Sutherland, Schwarzkopf, Taddei, Alva, Sciutti, Frick"
TITLE "Don giovanni-giulini 1/3"
FILE "C Dimage.ape "WAVE
track AUDIO
TITLE" Sinfonia "
Performer" Wächter, Sutherland, Schwarzkopf, Taddei, Alva, Sciutti, Frick "
INDEX 00:00:00
Track 0 2 AUDIO
TITLE "Notte e giorno faticar"
performer "Wächter, Sutherland, Schwarzkopf, Taddei, Alva, Sciutti, Frick "
INDEX 06:18:07
track AUDIO
& nbsp; TITLE "Non sperar, se Non m ' uccidi"
performer "Wächter, Sutherland, Schwarzkopf, Taddei , Alva, Sciutti, Frick "
INDEX 07:58:31
It should be stated that the information for an audio track may contain both index 00 and index 01, then the actual start time of the track is specified by index 01来. The value of index 01 is larger than index 00 to skip the blank portion of the track's front end. The time specified by index 01 is divided into three parts: minutes: seconds: 1/75 seconds.
After figuring out the format of the cue file, let's look at one of the features of the music editing software audacity: We can import a label file that contains information about each track, and then select Export Multiple. You can split the entire ape or FLAC file and convert it to a MP3 file. The format of the label file is as follows:
0.000000 0.000000 Sinfonia
378.093333 378.093333 notte e giorno faticar
478.413333 478.413333 Non sperar, se Non m ' Uccidi
where each line represents a track. The first column in each row is the same as the contents of the second column, which is the start time of the track, in seconds. The third column is the title of the track.
The conversion from cue to label file can be done online here, but it's not very convenient after all. So, I wrote a script cue2lbl.sh to implement the same functionality. The source code is as follows:
#!/bin/bashScript_name="cue2lbl.sh"Script_usage=$(Cat<<eof$script _name [OPTIONS] Cue_fileEOF)script_function=$(Cat<<eofConvert a cue CD index file to Audacity label file.EOF)Script_doc=$(Cat<<eofScript documentation.-H Display this help.-o Specify output lable file.EOF)Script_examples=$(Cat<<eof$script _name-o music.txt music.cueEOF)State_prefix="==="Warning_prefix="***"Error_prefix="!!!"functionDisplay_help () {if[-N"$script _usage"]; Then Echo-E"Usage: $script _usage" fi if[-N"$script _function"]; Then Echo-E"$script _function" fi if[-N"$script _doc"] ; Then Echo-E"\n$script_doc" fi if[-N"$script _examples"]; Then Echo-E"\nexamples" Echo-E"$script _examples" fi}# Output label fileLbl_file=""# Process Command Options whilegetopts ": Ho:"Opt Do Case$optinchh) display_helpExit0;; O)Lbl_file=$Optarg;;\?) Display_helpExit1;;Esac DoneShift$(($Optind-1))# Start Execute the commandif[-Z"$lbl _file"]; Then Lbl_file="${1%cue}txt"fi# Label file first time writingLbl_file_1st_write=1# searched state:0 for Start, 1 for track, 2 for title, 3 for index.searched_state=0Declare-I.Track_time_minute=0Track_time_second=0IFS=$' \ n ' forLineinch ' grep-i ' \ (index\) \|\ (title\) \|\ (track\) "" $ "; Do Case$searched_stateinch0)if[-N"' Echo '$ Line" | Grep-i track ' "]; Then searched_state=1fi;; 1)if[-N"' Echo '$ Line" | Grep-i "TITLE"`"]; Then # Remove Blanks at the beginning and end of a line Line=' echo ' $line ' | gawk-f/usr/local/bin/scripts/rmblank.awk ' # Get title Track_title=' echo ' $line ' | gawk-f/usr/local/bin/scripts/cue2lbl_get_title.awk ' Track_title=' echo ' $track _title "| gawk-f/usr/local/bin/scripts/rmblank.awk | tr-d \" ' searched_state=2fi;; 2)if[-N"' Echo '$ Line" | Grep-i "INDEX"`"]; Then # Remove Blanks at the beginning and end of a line Line=' echo ' $line ' | gawk-f/usr/local/bin/scripts/rmblank.awk ' # Get Track Index Line=' echo ' $line ' | gawk-f/usr/local/bin/scripts/cue2lbl_get_index.awk ' Track_index=' echo ' $line | gawk-f/usr/local/bin/scripts/rmblank.awk | cut-f 1-d "" | Tr-d "" ' if["$track _index"=" the"] || ["$track _index"="1"]; Then # Get Track Time Track_time=' echo ' $line | gawk-f/usr/local/bin/scripts/rmblank.awk | cut-f 2-d "" | Tr-d "" ' Track_time_minute=' echo ' $track _time "| cut-f 1-d": "| Gawk ' {if (Match ($, "^0+$")! = 0) {print "0";} else {gsub ("^0+", "" "); Print}} ' Track_time_second=' echo ' $track _time "| cut-f 2-d": "| Gawk ' {if (Match ($, "^0+$")! = 0) {print "0";} else {gsub ("^0+", "" "); Print}} ' Track_time_sub_second=' echo ' $track _time "| cut-f": "| Gawk ' {if (Match ($, "^0+$")! = 0) {print "0";} else {gsub ("^0+", "" "); Print}} ' Track_time_total_seconds=$(($Track_time_minute* 60 + $Track_time_second))Track_time_sub_second=' echo ' scale=6; $track _time_sub_second/75 "| BC ' if["$track _time_sub_second"="0"]; Then Track_time_sub_second=". 000000" fi Track_time_total_seconds=' echo ' $track _time_total_seconds$track_time_sub_second "' fi fi if[-N"' Echo '$ Line" | Grep-i "Track"`"]; Then # Print collected track information if["$lbl _file_1st_write"="1"]; Then Echo-E"$track _time_total_seconds\t$track_time_total_seconds\t$track_title">"$lbl _file" Lbl_file_1st_write=0Else Echo-E"$track _time_total_seconds\t$track_time_total_seconds\t$track_title">>"$lbl _file" fi searched_state=1fi;;Esac Done# Print The last collected track informationif["$lbl _file_1st_write"="1"]; Then Echo-E"$track _time_total_seconds\t$track_time_total_seconds\t$track_title">"$lbl _file"Else Echo-E"$track _time_total_seconds\t$track_time_total_seconds\t$track_title">>"$lbl _file"fi
In order to complete the string match, the script uses several gawk programs, respectively, as follows:
1. Remove the white space characters from the beginning and end of the line:
{ gsub("(^[[:blank:]]+) | ( [[: blank:]]+$]"" "); print;}
2. Delete index:
/^ (INDEX) | (index)/ {printgensub("^ (index) | ( index) [[: blank:]]+ "" ", 1);}
3. Delete title:
/^ (TITLE) | (title)/ {printgensub("^ (title) | ( title) [[: blank:]]+ "" ", 1);}
Now that you have a label file, you can use audacity to generate multiple MP3 files for ape and FLAC conversions.
Import the mp3 file into your phone
At present, my mobile phone is using "cool music" player, can be directly via wifi from the computer to the mobile phone songs. As shown, after opening "Cool Music", click on "Computer-Mobile song" At the bottom of the page:
Then open the browser on the computer, enter the address of the prompt, add the file.
Convert CD music to MP3 under Gnu/linux