summaryrefslogtreecommitdiff
path: root/plugins/Watrack/formats/fmt_ofr.pas
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Watrack/formats/fmt_ofr.pas')
-rw-r--r--plugins/Watrack/formats/fmt_ofr.pas74
1 files changed, 74 insertions, 0 deletions
diff --git a/plugins/Watrack/formats/fmt_ofr.pas b/plugins/Watrack/formats/fmt_ofr.pas
new file mode 100644
index 0000000000..73d58b68ff
--- /dev/null
+++ b/plugins/Watrack/formats/fmt_ofr.pas
@@ -0,0 +1,74 @@
+{OFR file}
+unit fmt_OFR;
+{$include compilers.inc}
+
+interface
+uses wat_api;
+
+function ReadOFR(var Info:tSongInfo):boolean; cdecl;
+
+implementation
+uses windows,common,io,tags,srv_format;
+
+type
+ tMain = packed record
+ ID :dword; // 'OFR '
+ Size :dword; //15
+ SamplesLo :dword;
+ SamplesHi :word;
+ SampleType :byte;
+ ChannelsMap:byte;
+ Samplerate :dword;
+ Encoder :word;
+ Compression:byte;
+ end;
+
+function ReadOFR(var Info:tSongInfo):boolean; cdecl;
+var
+ f:THANDLE;
+ Hdr:tMain;
+ Samples:int64;
+begin
+ result:=false;
+ f:=Reset(Info.mfile);
+ if f=THANDLE(INVALID_HANDLE_VALUE) then
+ exit;
+ ReadID3v2(f,Info);
+ BlockRead(f,Hdr,SizeOf(Hdr));
+ Samples:=Hdr.SamplesLo+Hdr.SamplesHi*$10000;
+ Info.channels:=Hdr.ChannelsMap+1;
+ Info.khz :=Hdr.Samplerate div 1000;
+ Info.total :=(Samples div Info.channels)*Info.khz;
+
+ ReadAPEv2(f,Info);
+ ReadID3v1(f,Info);
+ CloseHandle(f);
+ result:=true;
+end;
+
+var
+ LocalFormatLinkOFR,
+ LocalFormatLinkOFS:twFormat;
+
+procedure InitLink;
+begin
+ LocalFormatLinkOFR.Next:=FormatLink;
+
+ LocalFormatLinkOFR.This.proc :=@ReadOFR;
+ LocalFormatLinkOFR.This.ext :='OFR';
+ LocalFormatLinkOFR.This.flags:=0;
+
+ FormatLink:=@LocalFormatLinkOFR;
+
+ LocalFormatLinkOFS.Next:=FormatLink;
+
+ LocalFormatLinkOFS.This.proc :=@ReadOFR;
+ LocalFormatLinkOFS.This.ext :='OFS';
+ LocalFormatLinkOFS.This.flags:=0;
+
+ FormatLink:=@LocalFormatLinkOFS;
+end;
+
+initialization
+ InitLink;
+end.