Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   MOD Sounddateien - Texte extrahieren (https://www.delphipraxis.net/155185-mod-sounddateien-texte-extrahieren.html)

isilive 12. Okt 2010 11:18

MOD Sounddateien - Texte extrahieren
 
Hoi Leute,

ich möchte die Info-Texte, die in MOD-Dateien (Trackermusik: .xm, .s3m, .it, ...)gespeichert sind auslesen.

Weiss jemand wie die Texte in den Dateien abgelegt sind, oder ist es der beste Ansatz die gesamte Datei nach Textstrings zu durchforsten?

Beispiel:
Auf ModArchive.org gibts haufenweise Songs. Und einen Button "View internal texts". Wie krieg ich diese Texte aus der Songdatei? :roll:

isilive 16. Okt 2010 03:41

AW: MOD Sounddateien - Texte extrahieren
 
Jetzt hab ich mir eine Routine geschrieben, die sämtliche "sinnvollen" Strings aus der Datei extrahiert...
Nur leider ist da ziemlich viel Mist dabei :roll:
Gibts irgendwelche Regeln, bei welcher Art von .mod, .xm, ... Datei die Texte wo im File stehen müssen?
Ansonsten kommt nämlich sowas raus. Und ich hatte auch schon Dateien bei denen der interessante Text am Schluss steht...
Code:
Celestial Fantasia
SCRM@
#$%&'()*+,-
SWEEPCL2.RAW
===---
BKCLANG.RAW
    Celestial Fantasia
SYNTHBS6.RAW
===---
028.SND
.SMP
J*e:
            by        .
005.SND
.SMP
   BeaT / Osmosys    
030.SND
.SMP
O.}1
         
PURE1.RAW
  Completed in March '97
MACHINE1.RAW
.    California, USA
SHARPMAJ.RAW
     Est. Length 6:19     
SHARPMIN.RAW
                       
006.SND
.SMP
   -=Thanks=-
031.SND
.SMP
                     
051.SND
.SMP
*God--Creation & Salvation*
STRNGOCT.SMP
                        .
SYNTHCRD.RAW
   Future Crew--ST3
PURESQR.RAW
                       
063.SND
.SMP
     Purple Motion of
SCRS
  Aforementioned--     
   Big-time influence by
  listening to your songs
  too many times than is
  healthy for the average
  human being (my fault,
       not yours :)     .
                   
==--
     1997 Seth Peelle  
  bpeelle@mail.telis.org .
   www.drigon.com/~beat
J8K8
B0C0D0
J0K0
J(K(
B C D
J K
 H I
 H I
 H I
B@C@$@
B@C@$8
 H I
B@C@$8
B@C@$@
B@C@$8
@ A C
@#A#C
@&A&C
@(A(C
@+A+C
@3A3C
@6A6C
@8A8C
B@C@$8
zzzzz~]
{zyuxuxC
{u|{~.
|zvtttp,
|v{{}J
~{vqnnnd
Tz|xxx}X
}yvnoimT
:u|yyt|a
{snkegC
 `yywtwn*
xgh`b3
;uzwutt8
|e^^.
]uttntN
r8!$
r;!% 
;$% 
=#&
L"*!!
`'.""
h8-)#
mN/,(% 
i^81.("
lmG64,)$
rsY;72,*
zvmI891-!
ww\@=73(
~{oJ@<6/
{w^CA;-
zrPA@2
}yfGC4
zuYB6
....
und noch duzende/hunderte solcher Zeilen...

Sir Rufo 16. Okt 2010 07:07

AW: MOD Sounddateien - Texte extrahieren
 
Nun ich würde mal davon ausgehen, dass die MOD Dateien eine Struktur haben.

Google ist dein Freund und liefert z.B. sowas:
Code:
By: Gerald Gutierrez
----------------------------------------------------------------------
 > I'd appreciate recieving this mail also, if it's converning Sound
 > Blaster/Adlib or .MOD files. Just leave mail to Joshua Kersey in the
 > NETMail echo and I should get it, no need to post it twice.

There's no such thing as a 'NETMail echo' 8) Just netmail, and echos.
Seeing as sooOOooOoOoo many people seem to want this structure ( good luck
writing your mod player.. you'll need it BADLY ):

Protracker 1.1B Song/Module Format:
-----------------------------------
Offset Bytes Description
------  -----  -----------
   0     20    Songname. Remember to put trailing null bytes at the end...

Information for sample 1-31:

Offset Bytes Description
------  -----  -----------
  20     22    Samplename for sample 1. Pad with null bytes.
  42      2    Samplelength for sample 1. Stored as number of words.
               Multiply by two to get real sample length in bytes.
  44      1    Lower four bits are the finetune value, stored as a signed
               four bit number. The upper four bits are not used, and
               should be set to zero.
               Value: Finetune:
                 0        0
                 1       +1
                 2       +2
                 3       +3
                 4       +4
                 5       +5
                 6       +6
                 7       +7
                 8       -8
                 9       -7
                 A      -6
                 B      -5
                 C      -4
                 D      -3
                 E      -2
                 F      -1

  45      1    Volume for sample 1. Range is $00-$40, or 0-64 decimal.
  46      2    Repeat point for sample 1. Stored as number of words offset
               from start of sample. Multiply by two to get offset in bytes.
  48      2    Repeat Length for sample 1. Stored as number of words in
               loop. Multiply by two to get replen in bytes.

Information for the next 30 samples starts here. It's just like the info for
sample 1.

Offset Bytes Description
------  -----  -----------
  50     30    Sample 2...
  80     30    Sample 3...
   .
   .
   .
 890     30    Sample 30...
 920     30    Sample 31...

Offset Bytes Description
------  -----  -----------
 950      1    Songlength. Range is 1-128.
 951      1    Well... this little byte here is set to 127, so that old
               trackers will search through all patterns when loading.
               Noisetracker uses this byte for restart, but we don't.
 952    128    Song positions 0-127. Each hold a number from 0-63 that
               tells the tracker what pattern to play at that position.
1080      4    The four letters "M.K." - This is something Mahoney & Kaktus
               inserted when they increased the number of samples from
               15 to 31. If it's not there, the module/song uses 15 samples
               or the text has been removed to make the module harder to
               rip. Startrekker puts "FLT4" or "FLT8" there instead.

Offset Bytes Description
------  -----  -----------
1084    1024   Data for pattern 00.
   .
   .
   .
xxxx Number of patterns stored is equal to the highest patternnumber
      in the song position table (at offset 952-1079).

Each note is stored as 4 bytes, and all four notes at each position in
the pattern are stored after each other.

00 -  chan1  chan2  chan3  chan4
01 -  chan1  chan2  chan3  chan4
02 -  chan1  chan2  chan3  chan4
etc.

Info for each note:

 _____byte 1_____   byte2_    _____byte 3_____   byte4_
/                \ /      \  /                \ /      \
0000          0000-00000000  0000          0000-00000000

Upper four   12 bits for   Lower four   Effect command.
bits of sam-  note period.  bits of sam-
ple number.                 ple number.

Periodtable for Tuning 0, Normal
  C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
  C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
  C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113

To determine what note to show, scan through the table until you find
the same period as the one stored in byte 1-2. Use the index to look
up in a notenames table.

This is the data stored in a normal song. A packed song starts with the
four letters "PACK", but i don't know how the song is packed: You can
get the source code for the cruncher/decruncher from us if you need it,
but I don't understand it; I've just ripped it from another tracker...

In a module, all the samples are stored right after the patterndata.
To determine where a sample starts and stops, you use the sampleinfo
structures in the beginning of the file (from offset 20).
Ansonsten gibt es hier ein Link, da steht noch mehr

paperboy 16. Okt 2010 07:16

AW: MOD Sounddateien - Texte extrahieren
 
hallo isilive,

ich hab eben mal 2 xm datei verglichen... ist eigentlich relativ einfach an die gewünschten infos zu kommen...

am anfang der datei befindet sich eine ID ($00) = 'Extended module: '
ab $11 kommt der name des modules der 20 bytes in anspruch nimmt...
ab $26 dann noch der name des benutzten trackers..

danach folgen ein paar weitere infos wie länge, anzahl der instrumente etc. die aber nicht als string hinterlegt sind...

alle weiteren strings die sich in der datei befinden werden durch die bytefolge $07 $01 $00 $00 gekennzeichnet...

folgt auf diese bytefolge ein weiteres $00 ist es kein string...

das ist mal so auf die schnelle zusammengetragen...
hoffe das hilft die weiter...

lg paperboy

PS: die von Sir Rufo gegebene Seite enthält lustigerweise alles bis auf die infos wie strings gespeichert werden!
oder ich habs beim überfliegen übersehen :wink:

Sir Rufo 16. Okt 2010 07:19

AW: MOD Sounddateien - Texte extrahieren
 
Da steht ein Hinweis, dass am Ende von einem String $00 steht

toms 16. Okt 2010 07:51

AW: MOD Sounddateien - Texte extrahieren
 
Und wo ist der "interne Text" zu finden?

paperboy 16. Okt 2010 07:59

AW: MOD Sounddateien - Texte extrahieren
 
hey toms,

der "interne Text" ist in der xm datei verteilt gespeichert... vor einem teil des textes steht innerhalb der datei die bytefolge $07 $01 $00 $00 und wie Sir Rufo schon geschrieben hat wird das ende durch ein $00 gekennzeichnet...

warum da nicht einfach etwas platz im header für vorhanden ist würde mich mal interessieren...

lg paperboy

Gehstock 16. Okt 2010 08:37

AW: MOD Sounddateien - Texte extrahieren
 
Bei Protracker/Soundtracker u.a.(mod) Modulen gibt es keinen platz für Text also wurden nur die einzelnen Instrumente/Samples so umbenannt das in der Liste der Instrumente/Samples ein sinnvoller Text entstand dadurch gibt es keinen zusammenhängenden Text

paperboy 16. Okt 2010 11:11

AW: MOD Sounddateien - Texte extrahieren
 
ich hab mir grad ne kleine funktion gebastelt die die relevanten strings aus einer xm datei holt...
bei meinem versuch auch mod/it/669/s3m dateien auszulesen musste ich leider feststellen das die alle unterschiedliche regeln fürs speichern der strings haben :roll:

was ich in meinem ersten post geschrieben habe gilt also auch wirklich nur für xm dateien...

werd aus gründen der langeweile jetzt mal gucken ob ich für die anderen formate nicht auch noch schnell funktionen bauen kann...

lg paperboy

toms 16. Okt 2010 11:23

AW: MOD Sounddateien - Texte extrahieren
 
Liste der Anhänge anzeigen (Anzahl: 2)
Anbei ein Beispiel um MOD Samples auszulesen...
Muß evtl. für Delphi 2010/XE noch angepasst werden.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:40 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz