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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,4cad17e8664256c9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Allocation questions Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4a1e5d9e$0$2868$ba620e4c@news.skynet.be> Date: Thu, 28 May 2009 12:05:39 +0200 Message-ID: <106ssailgl19b$.1sngvazrm7u5w.dlg@40tude.net> NNTP-Posting-Date: 28 May 2009 12:05:39 CEST NNTP-Posting-Host: 48e348cc.newsspool1.arcor-online.net X-Trace: DXC=@]oCd3=JbSaEB;5>eE0T7mic==]BZ:afn4Fo<]lROoRa^YC2XCjHcbib_Ia1THOdUkDNcfSJ;bb[eFCTGGVUmh?dLK[5LiR>kgb5l4ijCIXnRa X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6061 Date: 2009-05-28T12:05:39+02:00 List-Id: On Thu, 28 May 2009 11:46:51 +0200, in comp.lang.ada you wrote: > 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; type Delay_T (Size : Natural) is tagged record Delay_Time: Time; Output : Sample; Samples : Samples_Array (1..Size); end record; (A side note, I suppose that Delay_Time is not of Time but of Duration.) > 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; function Create_Delay(Time_Value: Time) return Delay_T is Result : Delay_T (Natural (Time_Value * 44_100.0)); begin Result.Delay_Time := Time_Value; Result.Output := 0.0; return Result; end Create_Delay; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de