From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,4cad17e8664256c9,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!novso.com!news.skynet.be!195.238.0.222.MISMATCH!newsspl501.isp.belgacom.be!tjb!not-for-mail Date: Thu, 28 May 2009 11:46:51 +0200 From: Olivier Scalbert User-Agent: Thunderbird 2.0.0.21 (X11/20090409) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Allocation questions Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4a1e5d9e$0$2868$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 9210794c.news.skynet.be X-Trace: 1243504030 news.skynet.be 2868 87.65.198.18:35884 X-Complaints-To: usenet-abuse@skynet.be Xref: g2news2.google.com comp.lang.ada:6058 Date: 2009-05-28T11:46:51+02:00 List-Id: 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