Probh porovnvn soubor ToneGen.pas a \tmp\cul\cullib\tonegen.pas
****** ToneGen.pas
{ format of WAV file header }
 TWavHeader = record         { parameter description }
  rId             : longint; { 'RIFF'  4 characters }
  rLen            : longint; { length of DATA + FORMAT chunk }
  { FORMAT CHUNK }
  wId             : longint; { 'WAVE' }
  fId             : longint; { 'fmt ' }
  fLen            : longint; { length of FORMAT DATA = 16 }
  { format data }
  wFormatTag      : word;    { $01 = PCM }
  nChannels       : word;    { 1 = mono, 2 = stereo }
  nSamplesPerSec  : longint; { Sample frequency ie 11025}
  nAvgBytesPerSec : longint; { = nChannels * nSamplesPerSec *
                                (nBitsPerSample/8) }
  nBlockAlign     : word;    { = nChannels * (nBitsPerSAmple / 8 }
  wBitsPerSample  : word;    { 8 or 16 }
  { DATA CHUNK }
  dId             : longint; { 'data' }
  wSampleLength   : longint; { length of SAMPLE DATA }
  { sample data : offset 44 }
   { for 8 bit mono = s[0],s[1]... :byte}
   { for 8 bit stereo = sleft[0],sright[0],sleft[1],sright[1]... :byte}
   { for 16 bit mono = s[0],s[1]... :word}
   { for 16 bit stereo = sleft[0],sright[0],sleft[1],sright[1]... :word}
 end;

****** \tmp\cul\cullib\tonegen.pas
{ format of WAV file header }
  TWavHeader = record         { parameter description }
    rId             : longint; { 'RIFF'  4 characters }
    rLen            : longint; { length of DATA + FORMAT chunk }
    { FORMAT CHUNK }
    wId             : longint; { 'WAVE' }
    fId             : longint; { 'fmt ' }
    fLen            : longint; { length of FORMAT DATA = 16 }
    { format data }
    wFormatTag      : word;    { $01 = PCM }
    nChannels       : word;    { 1 = mono, 2 = stereo }
    nSamplesPerSec  : longint; { Sample frequency ie 11025}
    nAvgBytesPerSec : longint; { = nChannels * nSamplesPerSec *
                              (nBitsPerSample/8) }
    nBlockAlign     : word;    { = nChannels * (nBitsPerSAmple / 8 }
    wBitsPerSample  : word;    { 8 or 16 }
    { DATA CHUNK }
    dId             : longint; { 'data' }
    wSampleLength   : longint; { length of SAMPLE DATA }
    { sample data : offset 44 }
    { for 8 bit mono = s[0],s[1]... :byte}
    { for 8 bit stereo = sleft[0],sright[0],sleft[1],sright[1]... :byte}
    { for 16 bit mono = s[0],s[1]... :word}
    { for 16 bit stereo = sleft[0],sright[0],sleft[1],sright[1]... :word}
  end;

******

****** ToneGen.pas
begin
Inherited Create(AOwner);

HasChanged:=true;
HasADSRChanged:=true;
HasToneChanged:=true;
HasStopped:=true;

Buffer:=nil;

fFrequency:=FreDef;
fDuration:=DurDef;
fWaveform:=tgSine;
fAttack:=AttDef;
fDecay:=DecDef;
fSustain:=SusDef;
fRelease:=RelDef;
fAsync:=true;
fLoop:=false;
fResolution:=tg16Bit;
fQuality:=tgHiQ;
fLeftVolume:=VolDef;
fRightVolume:=VolDef;

DeviceID:=0;

//store volume settings
if (InstanceCount=0) and not(csDesigning in ComponentState)then
   begin
   //store original settings
   OriginalVolume:=GetVolume;

   //initialise volume
   SetVolume;

   end;

//increment instance count
Inc(TTGCount);

****** \tmp\cul\cullib\tonegen.pas
begin
  Inherited Create(AOwner);

  HasChanged:=true;
  HasADSRChanged:=true;
  HasToneChanged:=true;
  HasStopped:=true;

  Buffer:=nil;

  fFrequency:=FreDef;
  fDuration:=DurDef;
  fWaveform:=tgSine;
  fAttack:=AttDef;
  fDecay:=DecDef;
  fSustain:=SusDef;
  fRelease:=RelDef;
  fAsync:=true;
  fLoop:=false;
  fResolution:=tg16Bit;
  fQuality:=tgHiQ;
  fLeftVolume:=VolDef;
  fRightVolume:=VolDef;

  DeviceID:=0;

  //store volume settings
  if (InstanceCount=0) and not(csDesigning in ComponentState)then
     begin
     //store original settings
     OriginalVolume:=GetVolume;

     //initialise volume
     SetVolume;

     end;

  //increment instance count
  Inc(TTGCount);

******

****** ToneGen.pas

 wh.rId             := $46464952; { 'RIFF' }
 wh.rLen            := datasize+36;        { length of sample + format }
 wh.wId             := $45564157; { 'WAVE' }
 wh.fId             := $20746d66; { 'fmt ' }
 wh.fLen            := 16;        { length of format chunk }
 wh.wFormatTag      := 1;         { PCM data }
 wh.nChannels       := channels;  { mono/stereo }
 wh.nSamplesPerSec  := rate;      { sample rate }
 wh.nAvgBytesPerSec := channels*rate*(resolution div 8);
 wh.nBlockAlign     := channels*(resolution div 8);
 wh.wBitsPerSample  := resolution;{ resolution 8/16 }
 wh.dId             := $61746164; { 'data' }
 wh.wSampleLength   := datasize;         { sample size }

****** \tmp\cul\cullib\tonegen.pas

 wh.rId            := $46464952; { 'RIFF' }
 wh.rLen           := datasize+36;        { length of sample + format }
 wh.wId            := $45564157; { 'WAVE' }
 wh.fId            := $20746d66; { 'fmt ' }
 wh.fLen           := 16;        { length of format chunk }
 wh.wFormatTag     := 1;         { PCM data }
 wh.nChannels      := channels;  { mono/stereo }
 wh.nSamplesPerSec := rate;      { sample rate }
 wh.nAvgBytesPerSec := channels*rate*(resolution div 8);
 wh.nBlockAlign    := channels*(resolution div 8);
 wh.wBitsPerSample := resolution;{ resolution 8/16 }
 wh.dId            := $61746164; { 'data' }
 wh.wSampleLength  := datasize;         { sample size }

******

****** ToneGen.pas
   ResFactor: Integer;
   AttackV,DecayV,SustainV,ReleaseV: Integer;
   HiRes: bool;
****** \tmp\cul\cullib\tonegen.pas
   ResFactor: Integer;
   AttackV, DecayV, SustainV, ReleaseV: Integer;
   HiRes: bool;
******

****** ToneGen.pas
begin

if fResolution=tg16Bit then
   begin
   HiRes:=true;
   end
else
   begin
   HiRes:=false;
   end;

AttackV:=fAttack;
DecayV:=fDecay;
SustainV:=fSustain;
ReleaseV:=fRelease;

****** \tmp\cul\cullib\tonegen.pas
begin
  if fResolution=tg16Bit then begin
    HiRes:=true;
  end else begin
    HiRes:=false;
  end;

  AttackV:=fAttack;
  DecayV:=fDecay;
  SustainV:=fSustain;
  ReleaseV:=fRelease;

******

****** ToneGen.pas
//normalise percentages
if Total>100 then
   begin
   AttackV:=AttackV * 100 div Total;
   DecayV:=DecayV * 100 div Total;
   ReleaseV:=100-(AttackV+DecayV);
   SusDuration:=0;
   end;

SusDuration:=100-(AttackV+DecayV+ReleaseV);
Samples:=SusDuration * BufferSize div (100 * ResFactor);
if Samples<1 then
    begin
    SustainV:=0;
    end;

//sustain level
SusFactor:=SustainV/100;

Start:=0;

if HiRes then
  begin
  //create 16bit pointer
  iBuffer:=Pointer(Buf);
end;

****** \tmp\cul\cullib\tonegen.pas
//normalise percentages
  if Total>100 then begin
    AttackV := AttackV * 100 div Total;
    DecayV := DecayV * 100 div Total;
    ReleaseV := 100-(AttackV+DecayV);
    SusDuration := 0;
  end;

  SusDuration:=100-(AttackV+DecayV+ReleaseV);
  Samples:=SusDuration * BufferSize div (100 * ResFactor);
  if Samples<1 then begin
    SustainV:=0;
  end;

  //sustain level
  SusFactor:=SustainV/100;

  Start:=0;

  if HiRes then begin
    //create 16bit pointer
    iBuffer:=Pointer(Buf);
  end;

******


