-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Project : VHDL WAVE files
|
-- Project : VHDL WAVE files
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File : Wavefiles-p.vhd
|
-- File : Wavefiles-p.vhd
|
-- Author : Alexander Lindert <alexander_lindert at gmx.at>
|
-- Author : Alexander Lindert <alexander_lindert at gmx.at>
|
-- Created : 2008-08-19
|
-- Created : 2008-08-19
|
-- Last update: 2008-08-23
|
-- Last update: 2008-09-19
|
-- Platform :
|
-- Platform :
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Description: This package can read or write VHDL signals from or to wave files.
|
-- Description: This package can read or write VHDL signals from or to wave files.
|
-- There are no restriction for the numbers of channels and the sampling
|
-- There are no restriction for the numbers of channels and the sampling
|
-- frequences because Octave and Matlab can read them in every configuration.
|
-- frequences because Octave and Matlab can read them in every configuration.
|
-- Format used from this link:
|
-- Format used from this link:
|
-- http://www.lightlink.com/tjweber/StripWav/Canon.html
|
-- http://www.lightlink.com/tjweber/StripWav/Canon.html
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- GNU Lesser General Public License Version 3
|
-- GNU Lesser General Public License Version 3
|
-- =============================================
|
-- =============================================
|
-- Copyright 2005 by Sun Microsystems, Inc.
|
-- Copyright 2005 by Sun Microsystems, Inc.
|
-- 901 San Antonio Road, Palo Alto, CA 94303, USA
|
-- 901 San Antonio Road, Palo Alto, CA 94303, USA
|
--
|
--
|
-- This library is free software; you can redistribute it and/or
|
-- This library is free software; you can redistribute it and/or
|
-- modify it under the terms of the GNU Lesser General Public
|
-- modify it under the terms of the GNU Lesser General Public
|
-- License version 3, as published by the Free Software Foundation.
|
-- License version 3, as published by the Free Software Foundation.
|
--
|
--
|
-- This library is distributed in the hope that it will be useful,
|
-- This library is distributed in the hope that it will be useful,
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
-- Lesser General Public License for more details.
|
-- Lesser General Public License for more details.
|
--
|
--
|
-- You should have received a copy of the GNU Lesser General Public
|
-- You should have received a copy of the GNU Lesser General Public
|
-- License along with this library; if not, write to the Free Software
|
-- License along with this library; if not, write to the Free Software
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
-- MA 02111-1307 USA
|
-- MA 02111-1307 USA
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Revisions :
|
-- Revisions :
|
-- Date Version
|
-- Date Version
|
-- 2008-08-19 1.0
|
-- 2008-08-19 1.0
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
package WaveFiles is
|
package WaveFiles is
|
|
|
type aFileHandle is file of character;
|
type aFileHandle is file of character;
|
type aWaveDataTyp is (PCM8, PCM16LE, PCM32LE);
|
type aWaveDataTyp is (PCM8, PCM16LE, PCM32LE);
|
type aIntArray is array (natural range<>) of integer;
|
type aIntArray is array (natural range<>) of integer;
|
|
|
type aWaveFileInfo is record
|
type aWaveFileInfo is record
|
-- Handle : aFileHandle;
|
-- Handle : aFileHandle;
|
Channels : natural;
|
Channels : natural;
|
Datatyp : aWaveDataTyp;
|
Datatyp : aWaveDataTyp;
|
DataSize : integer;
|
DataSize : integer;
|
SamplingRate : natural;
|
SamplingRate : natural;
|
end record;
|
end record;
|
|
|
procedure OpenWaveFileRead(constant FileName : string;
|
procedure OpenWaveFileRead(constant FileName : string;
|
file WaveFileHandle : aFileHandle;
|
file WaveFileHandle : aFileHandle;
|
variable FileInfo : out aWaveFileInfo);
|
variable FileInfo : out aWaveFileInfo);
|
|
|
|
|
procedure ReadSample(file WaveFileHandle : aFileHandle;
|
procedure ReadSample(file WaveFileHandle : aFileHandle;
|
variable Sample : out integer;
|
variable Sample : out integer;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant DataTyp : aWaveDataTyp);
|
constant DataTyp : aWaveDataTyp);
|
|
|
procedure ReadSamples(file WaveFileHandle : aFileHandle;
|
procedure ReadSamples(file WaveFileHandle : aFileHandle;
|
variable Samples : out aIntArray;
|
variable Samples : out aIntArray;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant Channels : natural;
|
constant Channels : natural;
|
constant DataTyp : aWaveDataTyp);
|
constant DataTyp : aWaveDataTyp);
|
|
|
procedure OpenWaveFileWrite(constant FileName : string;
|
procedure OpenWaveFileWrite(constant FileName : string;
|
file WaveFileHandle : aFileHandle;
|
file WaveFileHandle : aFileHandle;
|
variable WaveFile : inout aWaveFileInfo);
|
variable WaveFile : inout aWaveFileInfo);
|
|
|
procedure WriteSample(file WaveFileHandle : aFileHandle;
|
procedure WriteSample(file WaveFileHandle : aFileHandle;
|
constant Sample : integer;
|
constant Sample : integer;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant DataTyp : aWaveDataTyp);
|
constant DataTyp : aWaveDataTyp);
|
|
|
procedure WriteSamples(file WaveFileHandle : aFileHandle;
|
procedure WriteSamples(file WaveFileHandle : aFileHandle;
|
constant Samples : aIntArray;
|
constant Samples : aIntArray;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant Channels : natural;
|
constant Channels : natural;
|
constant DataTyp : aWaveDataTyp);
|
constant DataTyp : aWaveDataTyp);
|
end;
|
end;
|
|
|
package body WaveFiles is
|
package body WaveFiles is
|
|
|
function ReadString(file WaveFileHandle : aFileHandle;
|
function ReadString(file WaveFileHandle : aFileHandle;
|
constant Name : string) return boolean is
|
constant Name : string) return boolean is
|
variable Ret : boolean := true;
|
variable Ret : boolean := true;
|
variable ch : character;
|
variable ch : character;
|
begin
|
begin
|
for i in Name'range loop
|
for i in Name'range loop
|
read(WaveFileHandle, ch);
|
read(WaveFileHandle, ch);
|
if ch /= Name(i) then
|
if ch /= Name(i) then
|
Ret := false;
|
Ret := false;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
return Ret;
|
return Ret;
|
end;
|
end;
|
|
|
function ReadDword(file WaveFileHandle : aFileHandle) return integer is
|
function ReadDword(file WaveFileHandle : aFileHandle) return integer is
|
variable Ret : integer := 0;
|
variable Ret : integer := 0;
|
variable temp : natural := 0;
|
|
variable ch : character;
|
variable ch : character;
|
begin
|
begin
|
for i in 0 to 3 loop
|
for i in 0 to 3 loop
|
read(WaveFileHandle, ch);
|
read(WaveFileHandle, ch);
|
temp := natural(character'pos(ch));
|
Ret := Ret + character'pos(ch)*2**(8*i);
|
Ret := Ret + temp*2**(8*i);
|
|
end loop;
|
end loop;
|
return Ret;
|
return Ret;
|
end;
|
end;
|
|
|
function ReadWord(file WaveFileHandle : aFileHandle) return integer is
|
function ReadWord(file WaveFileHandle : aFileHandle) return integer is
|
variable Ret : integer := 0;
|
variable Ret : integer := 0;
|
variable ch : character;
|
variable ch : character;
|
begin
|
begin
|
for i in 0 to 1 loop
|
for i in 0 to 1 loop
|
read(WaveFileHandle, ch);
|
read(WaveFileHandle, ch);
|
Ret := Ret + character'pos(ch)*2**(8*i);
|
Ret := Ret + character'pos(ch)*2**(8*i);
|
end loop;
|
end loop;
|
return Ret;
|
return Ret;
|
end;
|
end;
|
|
|
procedure OpenWaveFileRead(constant FileName : string;
|
procedure OpenWaveFileRead(constant FileName : string;
|
file WaveFileHandle : aFileHandle;
|
file WaveFileHandle : aFileHandle;
|
variable FileInfo : out aWaveFileInfo) is
|
variable FileInfo : out aWaveFileInfo) is
|
variable ch : character;
|
variable ch : character;
|
variable Dummy : integer;
|
variable Dummy : integer;
|
variable FileSize : natural;
|
variable FileSize : natural;
|
variable FileStatus : file_open_status;
|
variable FileStatus : file_open_status;
|
begin
|
begin
|
file_open(FileStatus, WaveFileHandle, FileName, read_mode);
|
file_open(FileStatus, WaveFileHandle, FileName, read_mode);
|
assert(FileStatus = open_ok)
|
assert(FileStatus = open_ok)
|
report "Cannot open file " & FileName & "!" severity failure;
|
report "Cannot open file " & FileName & "!" severity failure;
|
assert(ReadString(WaveFileHandle, "RIFF"))
|
assert(ReadString(WaveFileHandle, "RIFF"))
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
FileSize := ReadDWord(WaveFileHandle) +8; -- wrong dummy access!!!
|
FileSize := ReadDWord(WaveFileHandle) +8; -- wrong dummy access!!!
|
assert(ReadString(WaveFileHandle, "WAVE"))
|
assert(ReadString(WaveFileHandle, "WAVE"))
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
assert(ReadString(WaveFileHandle, "fmt "))
|
assert(ReadString(WaveFileHandle, "fmt "))
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
assert(ReadDWord(WaveFileHandle) = 16)
|
assert(ReadDWord(WaveFileHandle) = 16)
|
report "Uncommon header length, data will be corrupted!" severity failure;
|
report "Uncommon header length, data will be corrupted!" severity failure;
|
assert(ReadWord(WaveFileHandle) = 1)
|
assert(ReadWord(WaveFileHandle) = 1)
|
report "Cannot Handle any compressed file format" severity warning;
|
report "Cannot Handle any compressed file format" severity warning;
|
FileInfo.Channels := ReadWord(WaveFileHandle);
|
FileInfo.Channels := ReadWord(WaveFileHandle);
|
FileInfo.SamplingRate := ReadDword(WaveFileHandle);
|
FileInfo.SamplingRate := ReadDword(WaveFileHandle);
|
Dummy := ReadDword(WaveFileHandle); -- bytes/second
|
Dummy := ReadDword(WaveFileHandle); -- bytes/second
|
Dummy := ReadWord(WaveFileHandle); -- block align
|
Dummy := ReadWord(WaveFileHandle); -- block align
|
case ReadWord(WaveFileHandle) is
|
case ReadWord(WaveFileHandle) is
|
when 8 => FileInfo.DataTyp := PCM8;
|
when 8 => FileInfo.DataTyp := PCM8;
|
when 16 => FileInfo.DataTyp := PCM16LE;
|
when 16 => FileInfo.DataTyp := PCM16LE;
|
when 32 => FileInfo.DataTyp := PCM32LE;
|
when 32 => FileInfo.DataTyp := PCM32LE;
|
when others =>
|
when others =>
|
report "Not Implemented!" severity failure;
|
report "Not Implemented!" severity failure;
|
end case;
|
end case;
|
assert(ReadString(WaveFileHandle, "data"))
|
assert(ReadString(WaveFileHandle, "data"))
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
report "The file " & FileName & " is not a wave file!" severity failure;
|
FileInfo.DataSize := ReadDword(WaveFileHandle);
|
FileInfo.DataSize := ReadDword(WaveFileHandle);
|
end;
|
end;
|
|
|
|
|
|
function ReadSignedDword(file WaveFileHandle : aFileHandle) return integer is
|
|
variable Ret : integer := 0;
|
|
variable ch : character;
|
|
begin
|
|
for i in 0 to 3 loop
|
|
read(WaveFileHandle, ch);
|
|
Ret := Ret + character'pos(ch)*2**(8*i);
|
|
end loop;
|
|
return Ret;
|
|
end;
|
|
|
|
function ReadSignedWord(file WaveFileHandle : aFileHandle) return integer is
|
|
variable Ret : integer := 0;
|
|
variable ch : character;
|
|
begin
|
|
for i in 0 to 1 loop
|
|
read(WaveFileHandle, ch);
|
|
|
|
Ret := Ret + character'pos(ch)*2**(8*i);
|
|
end loop;
|
|
if Ret >= 2**15 then
|
|
Ret := Ret - 2**16;
|
|
end if;
|
|
return Ret;
|
|
end;
|
|
|
|
function ReadSignedByte(file WaveFileHandle : aFileHandle) return integer is
|
|
variable Ret : integer := 0;
|
|
variable ch : character;
|
|
begin
|
|
read(WaveFileHandle, ch);
|
|
Ret := character'pos(ch);
|
|
if Ret >= 2**7 then
|
|
Ret := Ret - 2**8;
|
|
end if;
|
|
return Ret;
|
|
end;
|
|
|
procedure ReadSample(file WaveFileHandle : aFileHandle;
|
procedure ReadSample(file WaveFileHandle : aFileHandle;
|
variable Sample : out integer;
|
variable Sample : out integer;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant DataTyp : aWaveDataTyp) is
|
constant DataTyp : aWaveDataTyp) is
|
variable Ret : integer := 0;
|
variable Ret : integer := 0;
|
variable ch : character;
|
variable ch : character;
|
begin
|
begin
|
if endfile(WaveFileHandle) = true then
|
if endfile(WaveFileHandle) = true then
|
if RemainingData < 0 then
|
if RemainingData < 0 then
|
report "Unexpected end of file!" severity error;
|
report "Unexpected end of file!" severity error;
|
else
|
else
|
report "End of file reached!" severity note;
|
report "End of file reached!" severity note;
|
end if;
|
end if;
|
else
|
else
|
case DataTyp is
|
case DataTyp is
|
when PCM8 =>
|
when PCM8 =>
|
read(WaveFileHandle, ch);
|
Ret := ReadSignedByte(WaveFileHandle);
|
Ret := character'pos(ch);
|
|
RemainingData := RemainingData-1;
|
RemainingData := RemainingData-1;
|
when PCM16LE =>
|
when PCM16LE =>
|
Ret := ReadWord(WaveFileHandle);
|
Ret := ReadSignedWord(WaveFileHandle);
|
RemainingData := RemainingData-2;
|
RemainingData := RemainingData-2;
|
when PCM32LE =>
|
when PCM32LE =>
|
Ret := ReadDword(WaveFileHandle);
|
Ret := ReadSignedDword(WaveFileHandle);
|
RemainingData := RemainingData-4;
|
RemainingData := RemainingData-4;
|
end case;
|
end case;
|
end if;
|
end if;
|
Sample := Ret;
|
Sample := Ret;
|
end;
|
end;
|
|
|
|
|
procedure ReadSamples(file WaveFileHandle : aFileHandle;
|
procedure ReadSamples(file WaveFileHandle : aFileHandle;
|
variable Samples : out aIntArray;
|
variable Samples : out aIntArray;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant Channels : natural;
|
constant Channels : natural;
|
constant DataTyp : aWaveDataTyp) is
|
constant DataTyp : aWaveDataTyp) is
|
variable Ret : aIntArray(0 to Channels-1);
|
variable Ret : aIntArray(0 to Channels-1);
|
begin
|
begin
|
for i in 0 to Channels-1 loop
|
for i in 0 to Channels-1 loop
|
ReadSample(WaveFileHandle, Ret(i), RemainingData, DataTyp);
|
ReadSample(WaveFileHandle, Ret(i), RemainingData, DataTyp);
|
end loop;
|
end loop;
|
Samples := Ret;
|
Samples := Ret;
|
end;
|
end;
|
|
|
procedure WriteString(file WaveFileHandle : aFileHandle;
|
procedure WriteString(file WaveFileHandle : aFileHandle;
|
constant Name : string) is
|
constant Name : string) is
|
begin
|
begin
|
for i in Name'range loop
|
for i in Name'range loop
|
write(WaveFileHandle, Name(i));
|
write(WaveFileHandle, Name(i));
|
end loop;
|
end loop;
|
end;
|
end;
|
|
|
procedure WriteChar(file WaveFileHandle : aFileHandle;
|
procedure WriteChar(file WaveFileHandle : aFileHandle;
|
constant Value : integer) is
|
constant Value : integer) is
|
variable ch : character;
|
variable ch : character;
|
variable to_ch : integer;
|
variable to_ch : integer;
|
begin
|
begin
|
to_ch := Value;
|
to_ch := Value;
|
if to_ch < 0 then
|
if to_ch < 0 then
|
to_ch := 2**8 + to_ch;
|
to_ch := 2**8 + to_ch;
|
end if;
|
end if;
|
ch := character'val(to_ch);
|
ch := character'val(to_ch);
|
write(WaveFileHandle, ch);
|
write(WaveFileHandle, ch);
|
end;
|
end;
|
|
|
procedure WriteDword(file WaveFileHandle : aFileHandle;
|
procedure WriteDword(file WaveFileHandle : aFileHandle;
|
constant Value : integer) is
|
constant Value : integer) is
|
variable temp : integer := 0;
|
variable temp : integer := 0;
|
variable to_ch : integer := 0;
|
variable to_ch : integer := 0;
|
begin
|
begin
|
temp := Value;
|
temp := Value;
|
for i in 0 to 3 loop
|
for i in 0 to 3 loop
|
to_ch := temp mod 2**8;
|
to_ch := temp mod 2**8;
|
WriteChar(WaveFileHandle, to_ch);
|
WriteChar(WaveFileHandle, to_ch);
|
temp := (temp-to_ch)/2**8;
|
temp := (temp-to_ch)/2**8;
|
end loop;
|
end loop;
|
end;
|
end;
|
|
|
procedure WriteWord(file WaveFileHandle : aFileHandle;
|
procedure WriteWord(file WaveFileHandle : aFileHandle;
|
constant Value : integer) is
|
constant Value : integer) is
|
variable temp : integer := 0;
|
variable temp : integer := 0;
|
variable to_ch : integer := 0;
|
variable to_ch : integer := 0;
|
begin
|
begin
|
temp := Value;
|
temp := Value;
|
for i in 0 to 1 loop
|
for i in 0 to 1 loop
|
to_ch := temp mod 2**8;
|
to_ch := temp mod 2**8;
|
WriteChar(WaveFileHandle, to_ch);
|
WriteChar(WaveFileHandle, to_ch);
|
temp := (temp-to_ch)/2**8;
|
temp := (temp-to_ch)/2**8;
|
end loop;
|
end loop;
|
end;
|
end;
|
|
|
|
|
procedure OpenWaveFileWrite(constant FileName : string;
|
procedure OpenWaveFileWrite(constant FileName : string;
|
file WaveFileHandle : aFileHandle;
|
file WaveFileHandle : aFileHandle;
|
variable WaveFile : inout aWaveFileInfo) is
|
variable WaveFile : inout aWaveFileInfo) is
|
variable ch : character;
|
variable ch : character;
|
variable Size : integer;
|
variable Size : integer;
|
variable FileStatus : file_open_status;
|
variable FileStatus : file_open_status;
|
begin
|
begin
|
file_open(FileStatus, WaveFileHandle, FileName, write_mode);
|
file_open(FileStatus, WaveFileHandle, FileName, write_mode);
|
assert(FileStatus = open_ok)
|
assert(FileStatus = open_ok)
|
report "Cannot open file " & FileName & "!" severity failure;
|
report "Cannot open file " & FileName & "!" severity failure;
|
WriteString(WaveFileHandle, "RIFF"); -- 4
|
WriteString(WaveFileHandle, "RIFF"); -- 4
|
Size := WaveFile.DataSize + 44 -8;
|
Size := WaveFile.DataSize + 44 -8;
|
WriteDword(WaveFileHandle, Size); -- 8
|
WriteDword(WaveFileHandle, Size); -- 8
|
WriteString(WaveFileHandle, "WAVE"); -- 12
|
WriteString(WaveFileHandle, "WAVE"); -- 12
|
WriteString(WaveFileHandle, "fmt "); -- 16
|
WriteString(WaveFileHandle, "fmt "); -- 16
|
Size := 16;
|
Size := 16;
|
WriteDWord(WaveFileHandle, Size); -- 20 size of format tag
|
WriteDWord(WaveFileHandle, Size); -- 20 size of format tag
|
Size := 1;
|
Size := 1;
|
WriteWord(WaveFileHandle, Size); -- 22 PCM stream
|
WriteWord(WaveFileHandle, Size); -- 22 PCM stream
|
WriteWord(WaveFileHandle, WaveFile.Channels); -- 24
|
WriteWord(WaveFileHandle, WaveFile.Channels); -- 24
|
WriteDWord(WaveFileHandle, WaveFile.SamplingRate); -- 28
|
WriteDWord(WaveFileHandle, WaveFile.SamplingRate); -- 28
|
case WaveFile.DataTyp is
|
case WaveFile.DataTyp is
|
when PCM8 => Size := 8;
|
when PCM8 => Size := 8;
|
when PCM16LE => Size := 16;
|
when PCM16LE => Size := 16;
|
when PCM32LE => Size := 32;
|
when PCM32LE => Size := 32;
|
end case;
|
end case;
|
WriteDWord(WaveFileHandle, WaveFile.SamplingRate*WaveFile.Channels*Size/8); -- bytes/second
|
WriteDWord(WaveFileHandle, WaveFile.SamplingRate*WaveFile.Channels*Size/8); -- bytes/second
|
WriteWord(WaveFileHandle, WaveFile.Channels*Size/8); -- block align
|
WriteWord(WaveFileHandle, WaveFile.Channels*Size/8); -- block align
|
WriteWord(WaveFileHandle, Size);
|
WriteWord(WaveFileHandle, Size);
|
WriteString(WaveFileHandle, "data");
|
WriteString(WaveFileHandle, "data");
|
WriteDWord(WaveFileHandle, WaveFile.DataSize);
|
WriteDWord(WaveFileHandle, WaveFile.DataSize);
|
end;
|
end;
|
|
|
procedure WriteSample(file WaveFileHandle : aFileHandle;
|
procedure WriteSample(file WaveFileHandle : aFileHandle;
|
constant Sample : integer;
|
constant Sample : integer;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant DataTyp : aWaveDataTyp) is
|
constant DataTyp : aWaveDataTyp) is
|
variable ch : character;
|
variable ch : character;
|
begin
|
begin
|
if RemainingData > 0 then
|
if RemainingData > 0 then
|
case DataTyp is
|
case DataTyp is
|
when PCM8 =>
|
when PCM8 =>
|
WriteChar(WaveFileHandle, Sample);
|
WriteChar(WaveFileHandle, Sample);
|
RemainingData := RemainingData -1;
|
RemainingData := RemainingData -1;
|
when PCM16LE =>
|
when PCM16LE =>
|
WriteWord(WaveFileHandle, Sample);
|
WriteWord(WaveFileHandle, Sample);
|
RemainingData := RemainingData -2;
|
RemainingData := RemainingData -2;
|
when PCM32LE =>
|
when PCM32LE =>
|
WriteDword(WaveFileHandle, Sample);
|
WriteDword(WaveFileHandle, Sample);
|
RemainingData := RemainingData -4;
|
RemainingData := RemainingData -4;
|
end case;
|
end case;
|
else
|
else
|
report "Wave file is full, have you forgotten to set the data size for OpenWaveFileWrite!" severity error;
|
report "Wave file is full, have you forgotten to set the data size for OpenWaveFileWrite!" severity error;
|
end if;
|
end if;
|
end;
|
end;
|
|
|
procedure WriteSamples(file WaveFileHandle : aFileHandle;
|
procedure WriteSamples(file WaveFileHandle : aFileHandle;
|
constant Samples : aIntArray;
|
constant Samples : aIntArray;
|
variable RemainingData : inout natural;
|
variable RemainingData : inout natural;
|
constant Channels : natural;
|
constant Channels : natural;
|
constant DataTyp : aWaveDataTyp) is
|
constant DataTyp : aWaveDataTyp) is
|
begin
|
begin
|
for i in 0 to Channels-1 loop
|
for i in 0 to Channels-1 loop
|
WriteSample(WaveFileHandle, Samples(i), RemainingData, DataTyp);
|
WriteSample(WaveFileHandle, Samples(i), RemainingData, DataTyp);
|
end loop;
|
end loop;
|
end;
|
end;
|
|
|
end;
|
end;
|
|
|
|
|