October 31, 2025, 11:49:30 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Looking for some old code

Started by ExMember001, August 23, 2009, 05:32:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

Hi,
I was wondering if someone here have the code of my old program MFS (mp3 files sorter)
I made it, long time ago, in IBasic pro but i lost it in a hd crash.


Barney

Perhaps this?


/*
Example + Subs to read and write mp3 id3tags v1.1 by krYpT
*/

'Use to read mp3 tags
Type MP3Info,128
   Dim Tag[3]:IString
   Dim Title[30]:IString
   Dim Artist[30]:IString
   Dim Album[30]:IString
   Dim Year[4]:IString
   Dim Comment[29]:IString
   Dim track:Char
   Dim Genre:Char
EndType
DEF Info:MP3Info

string tag,title,artist,album,comment,track,genre,year

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

OpenConsole

'Get full mp3 file path
mp3Path=FileRequest("Open Mp3 File",0,1)

'Read the tag
ReadId3v1(mp3Path)

'Print Result
Print "Title     = "+title
Print "Artist    = "+Artist
Print "Album     = "+Album
Print "Year      = "+Year
Print "Comment   = "+Comment
Print "Genre     = "+Genre
Print "Track     = "+Track

LOCATE 12,1
Print "PRESS ESC Key To Quit Or 1 to Set New tags"

Do
cmd=Inkey$
Until cmd<>""

Select cmd

      Case "ESC"

          closeconsole
          end

      CASE "1"

          CLS
          'Get tag all into strings
          Input "Input Title      : ",Title
          Input "Input Artist Name: ",Artist
          Input "Input Album Name : ",Album
          Input "Input Year       : ",Year
          Input "Input Comments   : ",Comment
          Input "Input Genre as Number   : ",Genre
          Input "Input Track      : ",Track

          'Write tag to mp3 File
          WriteId3Tags(Title,Artist,Album,Year,Comment,Genre,Track,Mp3Path)

          'Read tags again
          ReadId3v1(mp3Path)

          CLS
          'Print result
          Print "Title     = "+title
          Print "Artist    = "+Artist
          Print "Album     = "+Album
          Print "Year      = "+Year
          Print "Comment   = "+Comment
          Print "Genre     = "+Genre
          Print "Track     = "+Track

          LOCATE 12,1
          Print "Press any Key To Close"

          Do:Until Inkey$<>""
          CloseConsole
          End

endselect

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub ReadId3v1(mp3path:String)
/*
Description : Read id3tags v1.1
Para        : mp3path is the full path to the mp3 file
Return      : title,artist,album,year,comment,genre,track as strings
-KrYpT
*/
BFILE mp3
INT t

IF(OPENFILE(mp3,mp3path,"R")=0)

  /* the id3tag (if exist) should be the last 128 bytes of the the file */
  Seek mp3,len(mp3)-128
  /* then we read the data and put it into the structure */
  Read mp3,info
  CLOSEFILE mp3

  'if the first 3 bytes of the tag are TAG
  tag = ""
  for t = 0 to 2
     tag += info.tag[t]
  next t
  If tag = "TAG"   

    'Get the genre
    Genre = STR$(info.Genre)
    'Convert Genre into string
    ConvertGenre(Genre)

    Track = STR$(Info.Track)   
    if (Track = STR$(32))|(Track = STR$(0))
      Track = ""
    Endif

    title = ""
    artist = ""
    album = ""
    comment = ""
    year = ""

    'Read bytes one by one
    for t = 0 to 29
       title += info.Title[t]
    next t
    for t = 0 to 29
       Artist += info.Artist[t]
    next t
    for t = 0 to 29
       album += info.album[t]
    next t
    for t = 0 to 3
       Year += info.Year[t]
    next t
    for t = 0 to 28
       Comment += info.Comment[t]
    next t

    'Trim Free spaces
    title = RTRIM$(title)
    artist = RTRIM$(artist)
    album = RTRIM$(album)
    year = RTRIM$(year)   
    Genre = RTRIM$(Genre)   
    comment = RTRIM$(comment)
    Track= LTRIM$(Track)

  endif
endif

return
Endsub

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub WriteId3Tags(Title:String,Artist:String,Album:String,Year:String,Comment:String,Genre:String,Track:String,Mp3Path:String)
/*
Description : Write Id3tags v1.1 to an mp3 file
Para        : Genre = a number from 0 to 147 into a string
            : mp3path = Full path to the mp3 file
            : The rest is self explained
-KrYpT
*/
INT Lenght
BFILE Mp3

/*check if file is readable */
If OpenFile(mp3,mp3Path,"R")=0
  Seek mp3,Len(mp3)-128
  Read mp3,info
  closefile mp3

    lenght = len(title)
    if lenght <= 29
      for t = 1 to (29-lenght)
      title += " "
      next t
      info.title = title
    else
      if lenght <= 30
        info.title = title
      endif
    endif

    lenght = len(Artist)
    if lenght <= 29
      for t = 1 to (29-lenght)
      Artist += " "
      next t
      info.Artist = Artist
    else
      if lenght <= 30
        info.Artist = Artist
      endif
    endif

    lenght = len(Album)
    if lenght <= 29
      for t = 1 to (29-lenght)
      Album += " "
      next t
      info.Album = Album
    else
      if lenght <= 30
        info.Album = Album
      endif
    endif

    lenght = len(Year)
    if lenght <= 3
      for t = 1 to (3-lenght)
      Year += " "
      next t
      info.Year = Year
    else
      if lenght <= 4
        info.Year = Year
      endif
    endif

    lenght = len(Comment)
    if lenght <= 28
      for t = 1 to (28-lenght)
      Comment += " "
      next t
      info.Comment = Comment
    else
      if lenght <= 29
        info.Comment = Comment
      endif
    endif

    info.track=val(track)
    info.Genre=val(Genre)

    /* write tag to mp3 */
    OpenFile(mp3,mp3Path,"a")
    Seek mp3,Len(mp3)-128
    Write mp3,info
    CloseFile mp3

else

  Messagebox "","Sorry but this file cannot be openned" , "Warning"

endif

return
EndSub

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub ConvertGenre(Genre:String),String   
if Genre = str$(0) then Genre = "Blues"     
if Genre = str$(1) then Genre = "Classic Rock"     
if Genre = str$(2) then Genre = "Country"     
if Genre = str$(3) then Genre = "Dance"     
if Genre = str$(4) then Genre = "Disco"     
if Genre = str$(5) then Genre = "Funk"     
if Genre = str$(6) then Genre = "Grunge"     
if Genre = str$(7) then Genre = "Hip-Hop"   
if Genre = str$(8) then Genre = "Jazz"     
if Genre = str$(9) then Genre = "Metal"     
if Genre = str$(10) then Genre = "New Age"     
if Genre = str$(11) then Genre = "Oldies"     
if Genre = str$(12) then Genre = "Other"     
if Genre = str$(13) then Genre = "PoP"   
if Genre = str$(14) then Genre = "R&B"   
if Genre = str$(15) then Genre = "Rap"     
if Genre = str$(16) then Genre = "Reggae"     
if Genre = str$(17) then Genre = "Rock"     
if Genre = str$(18) then Genre = "Techno"     
if Genre = str$(19) then Genre = "Industriel"     
if Genre = str$(20) then Genre = "Alternative"     
if Genre = str$(21) then Genre = "Ska"     
if Genre = str$(22) then Genre = "Death Metal"     
if Genre = str$(23) then Genre = "Pranks"     
if Genre = str$(24) then Genre = "Soundtrack"     
if Genre = str$(25) then Genre = "Euro-Techno"     
if Genre = str$(26) then Genre = "Ambient"     
if Genre = str$(27) then Genre = "Trip-Hop"     
if Genre = str$(28) then Genre = "Vocal"     
if Genre = str$(29) then Genre = "Jazz+Funk"     
if Genre = str$(30) then Genre = "Fusion"     
if Genre = str$(31) then Genre = "Trance"     
if Genre = str$(32) then Genre = "Classical"     
if Genre = str$(33) then Genre = "Instrumental"   
if Genre = str$(34) then Genre = "Acid"     
if Genre = str$(35) then Genre = "House"     
if Genre = str$(36) then Genre = "Game"     
if Genre = str$(37) then Genre = "SoundClip"     
if Genre = str$(38) then Genre = "Gospel"     
if Genre = str$(39) then Genre = "Noise"     
if Genre = str$(40) then Genre = "AlternRock"     
if Genre = str$(41) then Genre = "Bass"     
if Genre = str$(42) then Genre = "Soul"     
if Genre = str$(43) then Genre = "Punk"   
if Genre = str$(44) then Genre = "Space"     
if Genre = str$(45) then Genre = "Meditative"   
if Genre = str$(46) then Genre = "Instrumental Pop"     
if Genre = str$(47) then Genre = "Instrumental Rock"     
if Genre = str$(48) then Genre = "Ethnic"     
if Genre = str$(49) then Genre = "Gothic"     
if Genre = str$(50) then Genre = "Darkwave"     
if Genre = str$(51) then Genre = "Techno-Industrial"     
if Genre = str$(52) then Genre = "Electronic"     
if Genre = str$(53) then Genre = "Pop-Folk"     
if Genre = str$(54) then Genre = "Eurodance"     
if Genre = str$(55) then Genre = "Dream"     
if Genre = str$(56) then Genre = "Southern Rock"   
if Genre = str$(57) then Genre = "Comedy"     
if Genre = str$(58) then Genre = "Cult"     
if Genre = str$(59) then Genre = "Gangsta"     
if Genre = str$(60) then Genre = "Top 40"     
if Genre = str$(61) then Genre = "Christian Rap"     
if Genre = str$(62) then Genre = "Pop/Funk"     
if Genre = str$(63) then Genre = "Jungle"     
if Genre = str$(64) then Genre = "Native US"     
if Genre = str$(65) then Genre = "Cabaret"     
if Genre = str$(66) then Genre = "New Wave"     
if Genre = str$(67) then Genre = "Psychadelic"     
if Genre = str$(68) then Genre = "Rave"     
if Genre = str$(69) then Genre = "Showtunes"     
if Genre = str$(70) then Genre = "Trailer"     
if Genre = str$(71) then Genre = "Lo-Fi"     
if Genre = str$(72) then Genre = "Tribal"     
if Genre = str$(73) then Genre = "Acid Punk"     
if Genre = str$(74) then Genre = "Acid Jazz"     
if Genre = str$(75) then Genre = "Polka"     
if Genre = str$(76) then Genre = "Retro"     
if Genre = str$(77) then Genre = "Musical"     
if Genre = str$(78) then Genre = "Rock & Roll"     
if Genre = str$(79) then Genre = "Hard Rock"     
if Genre = str$(80) then Genre = "Folk"     
if Genre = str$(81) then Genre = "Folk-Rock"     
if Genre = str$(82) then Genre = "National Folk"     
if Genre = str$(83) then Genre = "Swing"     
if Genre = str$(84) then Genre = "Fast Fusion"     
if Genre = str$(85) then Genre = "Bebop"   
if Genre = str$(86) then Genre = "Latin"   
if Genre = str$(87) then Genre = "Revival"   
if Genre = str$(88) then Genre = "Celtic"   
if Genre = str$(89) then Genre = "Bluegrass"   
if Genre = str$(90) then Genre = "Avantgarde"     
if Genre = str$(91) then Genre = "Gothic Rock"     
if Genre = str$(92) then Genre = "Progressive Rock"     
if Genre = str$(93) then Genre = "Psychedelic Rock"     
if Genre = str$(94) then Genre = "Symphonic Rock"     
if Genre = str$(95) then Genre = "Slow Rock"     
if Genre = str$(96) then Genre = "Big Band"     
if Genre = str$(97) then Genre = "Chorus"     
if Genre = str$(98) then Genre = "Easy Listening"     
if Genre = str$(99) then Genre = "Acoustic"     
if Genre = str$(100) then Genre = "Humour"     
if Genre = str$(101) then Genre = "Speech"     
if Genre = str$(102) then Genre = "Chanson"     
if Genre = str$(103) then Genre = "Opera"     
if Genre = str$(104) then Genre = "Chamber Music"     
if Genre = str$(105) then Genre = "Sonata"     
if Genre = str$(106) then Genre = "Symphony"     
if Genre = str$(107) then Genre = "Booty Bass"     
if Genre = str$(108) then Genre = "Primus"     
if Genre = str$(109) then Genre = "#&!! Groove"     
if Genre = str$(110) then Genre = "Satire"   
if Genre = str$(111) then Genre = "Slow Jam"     
if Genre = str$(112) then Genre = "Club"     
if Genre = str$(113) then Genre = "Tango"     
if Genre = str$(114) then Genre = "Samba"     
if Genre = str$(115) then Genre = "Folklore"     
if Genre = str$(116) then Genre = "Ballad"     
if Genre = str$(117) then Genre = "Power Ballad"     
if Genre = str$(118) then Genre = "Rhytmic Soul"     
if Genre = str$(119) then Genre = "Freestyle"     
if Genre = str$(120) then Genre = "Duet"     
if Genre = str$(121) then Genre = "Punk Rock"     
if Genre = str$(122) then Genre = "Drum Solo"     
if Genre = str$(123) then Genre = "Acapella"     
if Genre = str$(124) then Genre = "Euro-House"     
if Genre = str$(125) then Genre = "Dance Hall"   
if Genre = str$(126) then Genre = "Goa"     
if Genre = str$(127) then Genre = "Drum & Bass"   
if Genre = str$(128) then Genre = "Club-House"     
if Genre = str$(129) then Genre = "Hardcore"     
if Genre = str$(130) then Genre = "Terror"     
if Genre = str$(131) then Genre = "Indie"     
if Genre = str$(132) then Genre = "BritPop"     
if Genre = str$(133) then Genre = "Negerpunk"     
if Genre = str$(134) then Genre = "Polsk Punk"     
if Genre = str$(135) then Genre = "Beat"     
if Genre = str$(136) then Genre = "Christian Gangsta Rap"     
if Genre = str$(137) then Genre = "Heavy Metal"     
if Genre = str$(138) then Genre = "Black Metal"     
if Genre = str$(139) then Genre = "Crossover"   
if Genre = str$(140) then Genre = "Contemporary Christian"     
if Genre = str$(141) then Genre = "Christian Rock"     
if Genre = str$(142) then Genre = "Merengue"     
if Genre = str$(143) then Genre = "Salsa"     
if Genre = str$(144) then Genre = "Trash Metal"     
if Genre = str$(145) then Genre = "Anime"     
if Genre = str$(146) then Genre = "Jpop"     
if Genre = str$(147) then Genre = "Synthpop"   
if Genre = str$(255) then Genre = "Other"   
RETURN Genre   
EndSub

Compiles without problems in EB.

Barney

ExMember001

It was a part of it ;)
but i lost this one too...
Thanks so much !!!

Brian

Hi,

I think this zip contains everything

Brian

ExMember001

Thanks so much Brian !!
it is older than i though... was ibasic standard :)

i think i made an IB pro version of it too... v2.0 or higher if i remember well...

if anyone have it i'm still searching ;)

now time to try to recompile this old code back ...

Brian

Glad it was of some help, even though it was IBasic

I'll have another trawl tonight

Brian