JL35
Nombre de messages : 7112 Localisation : 77 Date d'inscription : 29/11/2007
| Sujet: Subs mp3 Lun 29 Sep 2014 - 21:52 | |
| Deux petites subs pour lecture ou modification des tags (infos) d'un fichier musique mp3, en panoramic pur (avec un exemple succinct d'utilisation): - Code:
-
DIM tag$, f$, titre$, artiste$, annee$, genre$, c$, i% DIM album$, piste%, comm$, an%, gen% tag$ = "C:\UTIL\tag.exe " f$ = "Z:\Unenoix.mp3" titre$ = "Chanson: 'Une noix'" artiste$ = "Jacques Douai" album$ = "" comm$ = "" an% = 2013 gen% = 76: ' Rétro piste% = 3: ' arbitraire
ModTagMp3(f$,titre$,artiste$,album$,an%,comm$,piste%,gen%) LirTagMp3(f$) MESSAGE CLIPBOARD_STRING_PASTE$: ' affichage des tags mis à jour TERMINATE ' ============================================================================== SUB LirTagMp3(f$) ' infos d'un MP3: Lecture des tags ID3v1 (128 derniers octets du fichier) ' résultat dans le clipboard. DIM_LOCAL a$,b$,d$,rc$,sz%,i%,j%,dl%,v%(128) DATA "Genres_MP3" DATA "Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop" DATA "Jazz","Metal","New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock" DATA "Techno","Industrial","Alternative","Ska","Death Metal","Pranks","Soundtrack" DATA "Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk","Fusion","Trance","Classical" DATA "Instrumental","Acid","House","Game","Sound Clip","Gospel","Noise","AlternRock" DATA "Bass","Soul","Punk","Space","Meditative","Instrumental Pop","Instrumental Rock" DATA "Ethnic","Gothic","Darkwave","Techno-Industrial","Electronic","Pop-Folk","Eurodance" DATA "Dream","Southern Rock","Comedy","Cult","Gangsta","Top 40","Christian Rap" DATA "Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychadelic","Rave" DATA "Showtunes","Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka","Retro" DATA "Musical","Rock & Roll","Hard Rock","Folk","Folk/Rock","National Folk","Swing" DATA "Fast-Fusion","Bebob","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic Rock" DATA "Progressive Rock","Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band" DATA "Chorus","Easy Listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber Music" DATA "Sonata","Symphony","Booty Bass","Primus","Porn Groove","Satire","Slow Jam" DATA "Club","Tango","Samba","Folklore","Ballad","Power Ballad","Rhythmic Soul","Freestyle" DATA "Duet","Punk Rock","Drum Solo","A capella","Euro-House","Dance Hall","Goa" DATA "Drum & Bass","Club House","Hardcore","Terror","Indie","BritPop","NegerPunk" DATA "Polsk Punk","Beat","Christian Gangsta","Heavy Metal","Black Metal","Crossover" DATA "Contemporary C","Christian Rock","Merengue","Salsa","Thrash Metal","Anime" DATA "JPop","SynthPop","" READ a$: WHILE a$<>"Genres_MP3": READ a$: END_WHILE dl%=1999: WHILE OBJECT_EXISTS(dl%)=1: dl%=dl%+1: END_WHILE: DLIST dl% READ a$: WHILE a$<>"": ITEM_ADD dl%,a$: READ a$: END_WHILE: j% = COUNT(dl%) IF j%<255 THEN FOR i% = j%+1 TO 256: ITEM_ADD dl%,"(vide)": NEXT i% rc$ = CHR$(13)+CHR$(10) FILEBIN_OPEN_READ 9,f$: sz% = FILEBIN_SIZE(9) FILEBIN_POSITION 9,sz%-128: FILEBIN_BLOCK_READ 9,128,v%(0): ' 128 derniers octets FILEBIN_CLOSE 9 a$ = "": FOR i% = 0 TO 127: a$=a$+CHR$(v%(i%)): NEXT i% i% = INSTR(a$,"TAG") IF i%=0 THEN CLIPBOARD_STRING_COPY "Pas de Tags": EXIT_SUB: ' pas de balise 'TAG' a$ = MID$(a$,i%,128) b$="Titre: ": d$=MID$(a$,4,30): i%=INSTR(d$,CHR$(0)): IF i%>1 THEN b$=b$+LEFT$(d$,i%-1) b$=b$+rc$+"Artiste: ": d$=MID$(a$,34,30): i%=INSTR(d$,CHR$(0)): IF i%>1 THEN b$=b$+LEFT$(d$,i%-1) b$=b$+rc$+"Album: ": d$=MID$(a$,64,30): i%=INSTR(d$,CHR$(0)): IF i%>1 THEN b$=b$+LEFT$(d$,i%-1) b$ = b$+rc$+"Année: ": d$=MID$(a$,94,4): IF LEFT$(d$,1)<>CHR$(0) THEN b$=b$+d$ b$ = b$+rc$+"Comment: ": d$=MID$(a$,98,30): i%=INSTR(d$,CHR$(0)): IF i%>1 THEN b$=b$+LEFT$(d$,i%-1) b$ = b$+rc$+"Piste: "+STR$(ASC(MID$(a$,127,1))) i% = ASC(MID$(a$,128,1)): b$ = b$+rc$+"Genre: "+ITEM_READ$(dl%,i%+1) CLIPBOARD_STRING_COPY b$ DELETE dl% END_SUB ' ============================================================================== SUB ModTagMp3(f$,titre$,auteur$,album$,annee%,comm$,piste%,genre%) ' Création ou mise à jour des tags ID3v1 d'un fichier MP3 DIM_LOCAL v%(128),sz%,i%,ntag%,a$,b$,xt,lt ntag% = 0 FILEBIN_OPEN_READ 9,f$: sz% = FILEBIN_SIZE(9) FILEBIN_POSITION 9,sz%-128: FILEBIN_BLOCK_READ 9,128,v%(0) FILEBIN_CLOSE 9 a$ = "": FOR i% = 0 TO 127: a$=a$+CHR$(v%(i%)): NEXT i% IF LEFT$(a$,3) <> "TAG": ' pas de tags ID3v1 a$ = "TAG"+STRING$(125,CHR$(0)): ntag% = 1 END_IF IF titre$<>"" xt = 3: lt = 30: b$ = titre$: b$ = b$ + STRING$(lt-LEN(b$),CHR$(0)) a$=LEFT$(a$,xt)+b$+MID$(a$,xt+lt+1,128) END_IF IF auteur$<>"" xt = 33: lt = 30: b$ = auteur$: b$ = b$ + STRING$(lt-LEN(b$),CHR$(0)) a$=LEFT$(a$,xt)+b$+MID$(a$,xt+lt+1,128) END_IF IF album$<>"" xt = 63: lt = 30: b$ = album$: b$ = b$ + STRING$(lt-LEN(b$),CHR$(0)) a$=LEFT$(a$,xt)+b$+MID$(a$,xt+lt+1,128) END_IF IF annee%<>0 xt = 93: lt = 4: b$ = RIGHT$("000"+STR$(annee%),lt) a$=LEFT$(a$,xt)+b$+MID$(a$,xt+lt+1,128) END_IF IF comm$<>"" xt = 125: lt = 28: b$ = comm$: b$ = b$ + STRING$(lt-LEN(b$),CHR$(0)) a$=LEFT$(a$,xt)+b$+MID$(a$,xt+lt+1,128) END_IF IF piste%<>-1 xt = 126: a$=LEFT$(a$,xt)+CHR$(piste%)+MID$(a$,xt+2,128) END_IF IF genre%<256 xt = 127: a$=LEFT$(a$,xt)+CHR$(genre%) END_IF FOR i% = 0 TO 127: v%(i%)=ASC(MID$(a$,i%+1,1)): NEXT i% FILEBIN_OPEN_WRITE 9,f$ IF ntag% = 1 FILEBIN_POSITION 9,sz%: ' création: ajout en fin de fichier ELSE FILEBIN_POSITION 9,sz%-128: ' mise à jour END_IF FILEBIN_BLOCK_WRITE 9,128,v%(0) FILEBIN_CLOSE 9 END_SUB ' ==============================================================================
Dernière édition par JL35 le Mar 30 Sep 2014 - 23:17, édité 1 fois | |
|