It´s driving me nuts ... need some help! ;)

Please discuss general Delphi programming topics here.

Postby Johnny_Bit » August 2nd, 2006, 6:51 pm

can you try using streams and datapointers? It's safer and less problematic.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Sonicfire1980 » August 2nd, 2006, 7:21 pm

If anyone´s interested (attention: newbie code ;)):
http://www.prodyon-virtual-gear.com/wrongcode.jpg

@Johnny_Bit: yes? then i should take a closer look at tmemorystream and the like. have to learn all that first, i´m afraid :)
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Postby Sonicfire1980 » August 2nd, 2006, 8:15 pm

Image

As you see,not much code, but obviously something must be total wrong :?
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Postby very angry mobster » August 3rd, 2006, 11:10 am

Have you seen Tobybear's wavefile save/load units?WaveIOX.


vam
very angry mobster
Member
Member
 
Posts: 3
Joined: July 27th, 2006, 3:48 pm

Postby Johnny_Bit » August 3rd, 2006, 12:40 pm

vam: give it rest, sonic is close to his own solution, so why waste such effort?
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Sonicfire1980 » August 3rd, 2006, 1:04 pm

@vam: yes i know of this unit :) but i hope i´m able to do it alone and without it :wink: My problem is just - the last "test" in my code JPG ... the rest is working fine :?
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Postby Sonicfire1980 » August 3rd, 2006, 3:03 pm

So why on earth has no one an idea??
:shock: :lol:
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Postby Sonicfire1980 » August 3rd, 2006, 10:06 pm

Procedure TForm1.ProcessWave(FileName: String);
var
Wavbuffer: TSmallIntArray;
Header: TWaveHeader;
i: Integer;
Amp: Double;

begin
Amp := 0.5; // half the volume
LoadTheWave(Outputfile.Text, Wavbuffer, sizeOf(Header)+1); //laden der audio daten
for i := 0 to High(Wavbuffer) do
begin
Wavbuffer[i] := Floor(Wavbuffer[i]*Amp);
end;
SaveTheWave(Outputfile.Text, Wavbuffer, sizeOf(Header)+1);
end;

result: almost white noise in the wav file ... does someone know why? (that worked in my old code before i switched to filestreams) :?:

If i use e.g. Amp := 2 it correctly doubles the output volume - why doesn´t the other way around work?
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Postby Kambiz » August 4th, 2006, 12:11 pm

I just want to remind you that SmallInt has 2 bytes length.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Sonicfire1980 » August 4th, 2006, 6:57 pm

Thanks, Kambiz - i already found the problem , it was because the "+1"! :)

However, anoterh little thing that is scarping my head... am i missing something here? :) :

I want to append a block (50%) of reversed audio data at the end of my main buffer:
Code: Select all
WavEnd := High(Wavbuffer) div 2;


Code: Select all
      begin
          WavAdd := High(Wavbuffer);
          setlength(TempWavbuffer, WavAdd+WavEnd);

          // copy the whole main buffer into temp buffer
          for i := Low(TempWavbuffer) to WavAdd do
          begin
                TempWavbuffer[i] := Wavbuffer[i];
          end;

          // append 50% of main buffer at end
          for i := Low(TempWavbuffer) to WavEnd do
          begin
                TempWavbuffer[WavAdd+i] := Wavbuffer[WavEnd+i];
          end;
       end


Is this a wrong way to try that? Besides this i'm trying to update the
header with the correct length information like so:
Code: Select all
Header.DataBytes := Header.DataBytes + Header.DataBytes div 2;


...but obviously here's something wrong, either it crashes or the WAV files has an "invalid file size"!
:oops:

Any ideas ? :)
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Postby Kambiz » August 4th, 2006, 7:54 pm

Windows has a set of APIs for manipulating RIFF files (name of these functions start with mmIO). Why you don't use these functions?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Sonicfire1980 » August 4th, 2006, 8:03 pm

Kambiz wrote:Windows has a set of APIs for manipulating RIFF files (name of these functions start with mmIO). Why you don't use these functions?


Hmm...dont know, that would mean i would have to rewrite everything the third time ;)
Sonicfire1980
Active Member
Active Member
 
Posts: 16
Joined: July 25th, 2006, 3:33 am
Location: berlin,germany

Previous

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron