From: Olivier Scalbert <olivier.scalbert@algosyn.com>
Subject: Allocation questions
Date: Thu, 28 May 2009 11:46:51 +0200
Date: 2009-05-28T11:46:51+02:00 [thread overview]
Message-ID: <4a1e5d9e$0$2868$ba620e4c@news.skynet.be> (raw)
Hello,
In the context of my small audio project, I need to create an object to
introduce a delay in a signal. With some of these objects and other
stuff it is possible to simulate nice reverberation.
Here is the code (As delay is a reserved word in Ada, I use Delay_T as I
found nothing better !):
package audio.effect is
type Sample is new Float;
type Time is new Float;
type Samples_Array is array (Positive range <>) of Sample;
type Delay_T is tagged record
Delay_Time: Time;
Output : Sample;
Samples : access Samples_Array;
end record;
function Create_Delay (Time_Value: Time) return Delay_T;
procedure Input (D: Delay_T; Input: Sample);
function Output (D: Delay_T) return Sample;
procedure Next (D: Delay_T); -- compute next output
end audio.effect;
package body audio.effect is
function Create_Delay(Time_Value: Time) return Delay_T is
Result: Delay_T;
Nb_Samples: Integer;
begin
Result.Delay_Time := Time_Value;
Nb_Samples := Integer(Time_Value * 44_100.0);
Result.Samples := new Samples_Array(1..Nb_Samples);
Result.Output := 0.0;
return Result;
end Create_Delay;
procedure Input (D: Delay_T; Input: Sample) is
begin
null; --TBD
end Input;
function Output(D: Delay_T) return Sample is
begin
return D.Output;
end Output;
procedure Next(D: Delay_T) is
begin
null; --TBD
end Next;
end audio.effect;
-- --------------------------------
Here are my questions:
1) Is there a way to avoid the dynamic array allocation, as I do not
know the Time_Value at compile time ?
2) Is it possible to release the array automatically when the Delay
object died ?
3) I have read that there is a program call gnatmem to detect memory
leaks. Is there somewhere a package for Linux (Debian) ?
Thanks for the help,
Olivier
next reply other threads:[~2009-05-28 9:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 9:46 Olivier Scalbert [this message]
2009-05-28 10:02 ` Allocation questions Martin
2009-05-28 11:55 ` xavier grave
2009-05-28 12:19 ` Ludovic Brenta
2009-05-28 13:00 ` Georg Bauhaus
2009-05-28 23:13 ` Robert A Duff
2009-05-28 10:05 ` Dmitry A. Kazakov
2009-05-28 10:40 ` Martin
2009-05-28 12:32 ` Olivier Scalbert
2009-05-28 13:39 ` Martin
2009-05-28 13:57 ` Olivier Scalbert
2009-05-28 14:51 ` Adam Beneschan
2009-05-28 17:58 ` Randy Brukardt
2009-05-28 14:04 ` Dmitry A. Kazakov
2009-05-28 16:59 ` Jeffrey R. Carter
2009-05-28 17:26 ` Olivier Scalbert
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox