| View previous topic :: View next topic |
| Author |
Message |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 274
|
Posted: 02/08/06 18:51 Post subject: |
|
|
| can you try using streams and datapointers? It's safer and less problematic.
|
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 02/08/06 19:21 Post subject: |
|
|
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
|
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 02/08/06 20:15 Post subject: |
|
|
As you see,not much code, but obviously something must be total wrong
|
|
| Back to top |
|
 |
very angry mobster Member
Joined: 27 Jul 2006 Posts: 3
|
Posted: 03/08/06 11:10 Post subject: |
|
|
Have you seen Tobybear's wavefile save/load units?WaveIOX.
vam
|
|
| Back to top |
|
 |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 274
|
Posted: 03/08/06 12:40 Post subject: |
|
|
| vam: give it rest, sonic is close to his own solution, so why waste such effort?
|
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 03/08/06 13:04 Post subject: |
|
|
@vam: yes i know of this unit but i hope i´m able to do it alone and without it My problem is just - the last "test" in my code JPG ... the rest is working fine
|
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 03/08/06 15:03 Post subject: |
|
|
So why on earth has no one an idea??
|
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 03/08/06 22:06 Post subject: |
|
|
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?
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 04/08/06 12:11 Post subject: |
|
|
I just want to remind you that SmallInt has 2 bytes length.
_________________ Kambiz |
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 04/08/06 18:57 Post subject: |
|
|
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: |
WavEnd := High(Wavbuffer) div 2;
|
| Code: |
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: |
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"!
Any ideas ?
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 04/08/06 19:54 Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Sonicfire1980 Member
Joined: 25 Jul 2006 Posts: 16 Location: berlin,germany
|
Posted: 04/08/06 20:03 Post subject: |
|
|
| 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
|
|
| Back to top |
|
 |
|