220 26189 <01f6b6a7-2b1e-491a-a676-5fc8ad816aab@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Jim <sdjimmysmith@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Any interest to adding audio support to the std library?
Date: Sat, 4 Jun 2016 15:24:16 -0700 (PDT)
Lines: 709
Approved: news@gmane.org
Message-ID: <01f6b6a7-2b1e-491a-a676-5fc8ad816aab@isocpp.org>
References: <f490fd21-cf07-4d7b-8936-c71c97a1ab9d@isocpp.org>
 <CANh-dX=R4Oa0OPZSrL7c9PXGyAdvM2CCBdP9C+h--N4Vt-J=9g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3419_1679322864.1465079056460"
X-Trace: ger.gmane.org 1465079061 962 80.91.229.3 (4 Jun 2016 22:24:21 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 4 Jun 2016 22:24:21 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCD5NLOE5UIBBENKZW5AKGQEGFXLAKA@isocpp.org Sun Jun 05 00:24:21 2016
Return-path: <std-proposals+bncBCD5NLOE5UIBBENKZW5AKGQEGFXLAKA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f199.google.com ([209.85.192.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCD5NLOE5UIBBENKZW5AKGQEGFXLAKA@isocpp.org>)
	id 1b9JzQ-0006kb-2q
	for gclcip-std-proposals@m.gmane.org; Sun, 05 Jun 2016 00:24:20 +0200
Original-Received: by mail-pf0-f199.google.com with SMTP id s73sf166360773pfs.0
        for <gclcip-std-proposals@m.gmane.org>; Sat, 04 Jun 2016 15:24:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SEV1BJdKi+RAlGEPG+vJhRM6Et5E38rnfsmm3Y1wjV0=;
        b=qkJbM2cSptdI24DTjAMhhc+mUjoqg/Alu8Nsyhkbs5yfcZ1elHXTNW1J4hgahF2diG
         IEeM0edEEhF9D7xsq0IFomIYxA0u1Ent61jFbrayNN4sV6ZyFw2JiNnf7zJ8INEQ/Fvh
         Spw5MQUX3vruEsBhgFnCQsWRwv9c2fBEr/U2l5WJOGzphlcE+3uLx5qHh7PR2yztnCJQ
         ddSDTwJPhKeNe6EGATUHuMLyfC6Rq8UJ7gEje+Th994rVKSB5/oxpqD75tkitaoMkIgP
         sGJbBGliOeP1lytfxGAYVjoqdS+MX7A5o3thh1T3OrtNrzRYwRAiAKsVzF7JCWMZGxz1
         Q3Tw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SEV1BJdKi+RAlGEPG+vJhRM6Et5E38rnfsmm3Y1wjV0=;
        b=IvsQaDBYk83NYIj5pJA8QMWkXfzCy5MBFOk2u4/njfen7jmni51Z2PxMqcEn9y9Jbx
         GgntzqbdwXtrCzkSyUmEG7gicU+SgSu8HFntSnkgZbBw2T9jcSdPEO/IrMReNLNSOQL8
         n12iX/h7Bi1IyjMAJBB0DAmLMC5zLG6mh0X84iX5MkM/8oH0wGdQuuyNIr2zX3mx/wnx
         TJV/j01JhgWF3CkXLdNrj48D3mgF+onJ/nqaTqu7Kzj73oXN7d380oeMqS+aOWNvLIIO
         SxZaPUnDqKEs3vUO4IIBgxnmF/Vj/T/okBkPJtckDS08akS/GrLilgcXZHTh47Hqf+Va
         meIA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=SEV1BJdKi+RAlGEPG+vJhRM6Et5E38rnfsmm3Y1wjV0=;
        b=nLigNoLvDUzfkvynCoAsOJzZ0M6i5xpR1x3ylzukt+YCh/8STS0KXs44nyycQ9RLKA
         vk+k/HFl+vo1BztmS0xvm0dMqiZ1Ne0v3tJMEUddIJKa3vl55Ktdwa+hT0rOE1yoKu82
         x2XqMPDF6gmyfimbhxfkvyiiUEC1MXdG1+ntGqHvUJmSomIvrxl7MuLXUZDEx1tSGYH7
         /P0b28xtRtxsVnZJjKOHg102YNXNCJcnfxmyIdDjTG7Rg8rxE5c98p5G7dADwCSH9Evs
         v2oP4xRoGZR1IDcTCi/LiA3SX/8daT6ctNmLeR/qmjozenmBowlwJfRAPY/7APNBy8pp
         FvAw==
X-Gm-Message-State: ALyK8tJnrh4Wyr1URabMhuwWVfKzJEwGWSvD9fFhoVd79DKZKATfGU35K6VrRUJItv/r2w==
X-Received: by 10.66.80.37 with SMTP id o5mr7418904pax.13.1465079058945;
        Sat, 04 Jun 2016 15:24:18 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.125.210 with SMTP id b201ls292764itc.30.canary; Sat, 04 Jun
 2016 15:24:17 -0700 (PDT)
X-Received: by 10.36.53.137 with SMTP id k131mr158746ita.0.1465079057718;
        Sat, 04 Jun 2016 15:24:17 -0700 (PDT)
In-Reply-To: <CANh-dX=R4Oa0OPZSrL7c9PXGyAdvM2CCBdP9C+h--N4Vt-J=9g@mail.gmail.com>
X-Original-Sender: sdjimmysmith@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:26189
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26189>

------=_Part_3419_1679322864.1465079056460
Content-Type: multipart/alternative; 
	boundary="----=_Part_3420_2002602399.1465079056460"

------=_Part_3420_2002602399.1465079056460
Content-Type: text/plain; charset=UTF-8

Hi,

I think it would be more feasible and elegant to use a standard or *more* 
standard C++ media interface. Building on existing design used for the C++ 
boost networking APIs, and std::basic_ostream, std::basic_streambuf 
features, something like std::char_traits<sample>. Using an existing audio 
framework or creating a less common C++ approach to handling media, might 
break an architectual flow of the C++ standard.

The same backend ideas used for a networking API interface hold true for an 
audio interface. What we read and write to/from an audio interface are 
samples and the structure is the format settings. The same idea is used in 
networking, we can read and write raw protocol or more structured one like 
TCP packets. The audio format is like a protocol you setup between the 
hardware and software. The i/o features async, sync etc. will be to some 
extent picked up automatically from the existing backend interface. 
Capturing concepts this way in a low level implementation should make 
acceptance easier.


--Jim Smith

On Friday, June 3, 2016 at 11:43:42 AM UTC-4, Jeffrey Yasskin wrote:
>
> Is this based on an existing library? We're much more likely to adopt 
> a proposal that's been used widely than one that was invented for the 
> standard. 
>
> On Fri, Jun 3, 2016 at 2:37 AM,  <alexande...@gmail.com <javascript:>> 
> wrote: 
> > I have drafted some ideas on how I think the c++ std library could 
> support 
> > audio functionality. 
> > 
> > I know that audio functionality is a very operating specific problem, 
> but 
> > with the recent trend towards implementing a file-system library and 
> > possibly a graphics library I believe that audio would not be too much 
> of a 
> > reach anymore. 
> > 
> > Here are some of the ideas I have so far. I have both some code examples 
> of 
> > the intended usage as well as a list of the types needed to implement 
> the 
> > given examples. 
> > 
> > Please keep in mind my drafts are still very rough. 
> > 
> > 
> > CODE EXAMPLES 
> > 
> > //std::audio example 1 "single process" 
> > void example_1(){ 
> >     double sample_rate = 44100; 
> >     std::size_t frame_size =2; 
> >     std::size_t buffer_size=128; 
> > 
> >     std::audio_context<float> 
> > ctx{sample_rate,buffer_size,frame_size};//contruct from values 
> > 
> >     std::astream_process<float> proc(ctx,[](std::iastream const& input, 
> > std::oastream& output){ 
> >         std::frame_buffer<float>& buff = ctx.borrow_buffer();//borrow a 
> > buffer from the context for usage 
> >         //prevents the need for dynamic allocation of a temporary buffer 
> >         input>>buff;//stream data into buffer for manipulation 
> >         for(auto&& frame: buff){ 
> >             frame=0.0;//do something with audio 
> >         } 
> >         output<<buff;//stream to output 
> >     });//dsp object 
> >     //uses implied routing equivilent to 
> >     //std::aout<<proc<<std::ain; 
> >     // 
> > 
> >     proc.start(); 
> >     //do other stuff 
> >     proc.stop(); 
> > } 
> > 
> > //std::audio example 2 "process group" 
> > void example_2(){ 
> > 
> >     std::audio_context<float> ctx;//default context created with 
> > std::default_* values 
> > 
> >     //version 1: capture context via lambda 
> >     std::astream_process<float> proc1(ctx,[&ctx](std::iastream const& 
> input, 
> > std::oastream& output){ 
> >         std::frame_buffer<float>& buff = ctx.borrow_buffer(); 
> >         input>>buff; 
> >         for(auto&& frame: buff){ 
> >             frame*=0.5; 
> >         } 
> >         output<<buff; 
> >     });//dsp object 
> > 
> >     //version 2: have context passed as argument 
> >     std::astream_process<float> proc2(ctx,[](std::iastream const& input, 
> > std::oastream& output,std::audio_context<float> const& context){ 
> >         std::frame_buffer<float>& buff = ctx.borrow_buffer(); 
> >         input>>buff; 
> >         for(auto&& frame: buff){ 
> >             frame*=2.0; 
> >         } 
> >         output<<buff; 
> >     }); 
> > 
> >     std::process_group<float> pgroup;//a group of processes that will 
> happen 
> > consecutivley 
> >     pgroup.push(proc1);//add to group 
> >     pgroup.push(proc2);//add to group 
> > 
> >     //configure stream relationships in terms of std::ain / std:aout 
> > manually 
> >     //std::ain/std::aout are std::astream globals that refer to the 
> default 
> > audio inputs and outputs supplied by the context in use 
> >     //std::ain/std::aout will route the audio to the enpoint specified 
> by 
> > the context reference held by the process that is streaming the data 
> >     std::aout<<proc1<<proc2<<std::ain;//method 1 
> >     //std::ain>>proc2>>proc1>>std::aout;//method 2 
> > 
> >     pgroup.start(); 
> >     //do other stuff 
> >     pgroup.stop(); 
> > 
> > } 
> > 
> > 
> > //std::audio example 3 "audio files" 
> > void example_3(){ 
> > 
> >     std::audio_context<float> ctx; 
> > 
> >     std::astream_process<float> proc(ctx,[](std::iafstream const& input, 
> > std::oafstream& output){ 
> >         std::frame_buffer<float>& buff = ctx.borrow_buffer(); 
> >         input>>buff; 
> >         for(auto&& frame: buff){ 
> >             frame=0.0; 
> >         } 
> >         output<<buff; 
> >     });//dsp object 
> > 
> >     std::iafstream audio_file1(ctx,"filename1.extension");//an audio 
> file 
> > handle 
> >     std::oafstream audio_file2(ctx,"filename2.extension");//an audio 
> file 
> > handle 
> > 
> >     //routing 
> >     audio_file2<<proc<<audio_file1;//take input from file nad write to 
> file 
> >     //audio_file1>>proc>>audio_file2;//equivilent syntax 
> >     proc.start(); 
> >     //do other stuff 
> >     proc.stop(); 
> > } 
> > 
> > 
> > //std::audio example 4 "combination routing" 
> > void example_3(){ 
> > 
> >     std::audio_context<float> ctx; 
> >     //manually select hardware endpoints 
> >     std::size_t device_id = ctx.default_device_id(); 
> >     std::iastream input_device = 
> > ctx.get_device<std::input_device>(device_id); 
> >     std::oastream output_device = 
> > ctx.get_device<std::output_device>(device_id); 
> > 
> >     std::astream_process<float> proc(ctx,[](std::iastream const& input, 
> >                                             std::oastream& output, 
> >                                             std::iafstream const& 
> > input_file, 
> >                                              std::oafstream& 
> output_file){ 
> >         std::frame_buffer<float>& buff = ctx.borrow_buffer(); 
> >         (input + input_file)>>buff;//add streams to perform sum before 
> > writing to buffer 
> >         //or you could use seperate buffers 
> >         //like this 
> >         /* 
> >             std::frame_buffer<float> buff1; 
> >             std::frame_buffer<float> buff2; 
> > 
> >             input>>buff1; 
> >             input_file>>buff2; 
> >             buff1+=buff2;//buffer arithmatic 
> >         */ 
> >         output<<buff;//send the contents of buff to the hardware out and 
> the 
> > file out 
> >         output_file<<buff; 
> >     }); 
> > 
> >     std::iafstream audio_file1(ctx,"filename1.extension");//the actual 
> files 
> > to be used above 
> >     std::oafstream audio_file2(ctx,"filename2.extension"); 
> > 
> >     //connect the files to the process 
> >     //connect the hardware device to the process 
> >     audio_file2<<proc<<audio_file1;//take input from file 
> >     output_device<<proc<<input_device;//also take from hardware 
> >     proc.start(); 
> >     //do other stuff 
> >     proc.stop(); 
> > } 
> > 
> > 
> > 
> > REQUIRED LIBRARY MEMBERS 
> > 
> > 
> > namespace std{ 
> >     inline namespace audio{ 
> >         //working context for audio flow 
> >         template<typename> 
> >         class audio_context; 
> >         /* 
> >         *The context in which all audio data is centered. 
> >         *Contains: sampling rate, buffer size, frame size, etc... 
> >         *The values of ain,aout,afin,afout refer to the endpoints 
> defined by 
> > the context, when applied to routing on a porocess tied to the context 
> >         *think of a context as the program level driver object 
> >         */ 
> > 
> >         //audio streams (think like std::fstream and its friends) 
> >         class astream;//audio stream 
> >         class oastream;//output audio stream 
> >         class iastream;//input audio stream 
> >         class oafstream;//output audio file stream 
> >         class iafstream;//input audio file stream 
> > 
> > 
> >         //stream endpoints 
> >         class ain;//audio input endpoint 
> >         class aout;//audio output endpoint 
> >         class afin;//audio file input endpoint 
> >         class afout//audio file output endpoint 
> > 
> >         //stream processing 
> >         template<typename> 
> >         class astream_process;//a dsp process applied to a stream 
> > 
> >         template<typename> 
> >         class process_group;//a group of processes that will act as one 
> > 
> >         //containers 
> >         template<typename> 
> >         class frame_buffer;//a sequence container that is resizeable at 
> > runtime, but only with explicit resize calls. contains frames(see below) 
> >         /*Implementation note on frame_buffer 
> >          *frame_buffer is intended to hold N number of frames which 
> > themselves can hold M number of samples 
> >          *meaning that the total size in samples if frame_buffer = N * M 
> >          *ideally frame_buffers representation of its sample data will 
> be 
> > continuous in memory 
> >         */ 
> > 
> >         template<typename> 
> >         class frame;//a container that holds samples, thin array wrapper 
> > 
> > 
> >         //hardware representation 
> >         class device;//an audio device as recognized by the OS 
> >         class input_device;//an input device 
> >         class output_device;//an output device 
> > 
> >         // audio file formats 
> >         enum class afformat{ 
> >             raw,//raw headerless audio bytes, interpreted only by the 
> > settings of the context. 
> >             //best used for temporary storage within the life of a 
> context 
> >             wav, 
> >             flac//etc... 
> >         } 
> >     } 
> > } 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "ISO C++ Standard - Future Proposals" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to std-proposal...@isocpp.org <javascript:>. 
> > To post to this group, send email to std-pr...@isocpp.org <javascript:>. 
>
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f490fd21-cf07-4d7b-8936-c71c97a1ab9d%40isocpp.org. 
>
>

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/01f6b6a7-2b1e-491a-a676-5fc8ad816aab%40isocpp.org.

------=_Part_3420_2002602399.1465079056460
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<br><br>I think it would be more feasible and elegant t=
o use a standard or *more* standard C++ media interface. Building on existi=
ng design used for the C++ boost networking APIs, and std::basic_ostream, s=
td::basic_streambuf features, something like std::char_traits&lt;sample&gt;=
.. Using an existing audio framework or creating a less common C++ approach =
to handling media, might break an architectual flow of the C++ standard.<br=
><br>The same backend ideas used for a networking API interface hold true f=
or an audio interface. What we read and write to/from an audio interface ar=
e samples and the structure is the format settings. The same idea is used i=
n networking, we can read and write raw protocol or more structured one lik=
e TCP packets. The audio format is like a protocol you setup between the ha=
rdware and software. The i/o features async, sync etc. will be to some exte=
nt picked up automatically from the existing backend interface. Capturing c=
oncepts this way in a low level implementation should make acceptance easie=
r.<br><br><br>--Jim Smith<br><br>On Friday, June 3, 2016 at 11:43:42 AM UTC=
-4, Jeffrey Yasskin wrote:<blockquote class=3D"gmail_quote" style=3D"margin=
: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Is t=
his based on an existing library? We&#39;re much more likely to adopt
<br>a proposal that&#39;s been used widely than one that was invented for t=
he
<br>standard.
<br>
<br>On Fri, Jun 3, 2016 at 2:37 AM, =C2=A0&lt;<a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"xwvxNJ1UAQAJ" rel=3D"nofollow" onmous=
edown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;javascript:&#39;;return true;">alexande...@gmail.com</a>&gt; wrot=
e:
<br>&gt; I have drafted some ideas on how I think the c++ std library could=
 support
<br>&gt; audio functionality.
<br>&gt;
<br>&gt; I know that audio functionality is a very operating specific probl=
em, but
<br>&gt; with the recent trend towards implementing a file-system library a=
nd
<br>&gt; possibly a graphics library I believe that audio would not be too =
much of a
<br>&gt; reach anymore.
<br>&gt;
<br>&gt; Here are some of the ideas I have so far. I have both some code ex=
amples of
<br>&gt; the intended usage as well as a list of the types needed to implem=
ent the
<br>&gt; given examples.
<br>&gt;
<br>&gt; Please keep in mind my drafts are still very rough.
<br>&gt;
<br>&gt;
<br>&gt; CODE EXAMPLES
<br>&gt;
<br>&gt; //std::audio example 1 &quot;single process&quot;
<br>&gt; void example_1(){
<br>&gt; =C2=A0 =C2=A0 double sample_rate =3D 44100;
<br>&gt; =C2=A0 =C2=A0 std::size_t frame_size =3D2;
<br>&gt; =C2=A0 =C2=A0 std::size_t buffer_size=3D128;
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::audio_context&lt;float&gt;
<br>&gt; ctx{sample_rate,buffer_size,<wbr>frame_size};//contruct from value=
s
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::astream_process&lt;float&gt; proc(ctx,[](std::i=
astream const&amp; input,
<br>&gt; std::oastream&amp; output){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;float&gt;&amp; bu=
ff =3D ctx.borrow_buffer();//borrow a
<br>&gt; buffer from the context for usage
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //prevents the need for dynamic alloca=
tion of a temporary buffer
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 input&gt;&gt;buff;//stream data into b=
uffer for manipulation
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for(auto&amp;&amp; frame: buff){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 frame=3D0.0;//do somethi=
ng with audio
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 output&lt;&lt;buff;//stream to output
<br>&gt; =C2=A0 =C2=A0 });//dsp object
<br>&gt; =C2=A0 =C2=A0 //uses implied routing equivilent to
<br>&gt; =C2=A0 =C2=A0 //std::aout&lt;&lt;proc&lt;&lt;std::ain;
<br>&gt; =C2=A0 =C2=A0 //
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 proc.start();
<br>&gt; =C2=A0 =C2=A0 //do other stuff
<br>&gt; =C2=A0 =C2=A0 proc.stop();
<br>&gt; }
<br>&gt;
<br>&gt; //std::audio example 2 &quot;process group&quot;
<br>&gt; void example_2(){
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::audio_context&lt;float&gt; ctx;//default contex=
t created with
<br>&gt; std::default_* values
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 //version 1: capture context via lambda
<br>&gt; =C2=A0 =C2=A0 std::astream_process&lt;float&gt; proc1(ctx,[&amp;ct=
x](std::iastream const&amp; input,
<br>&gt; std::oastream&amp; output){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;float&gt;&amp; bu=
ff =3D ctx.borrow_buffer();
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 input&gt;&gt;buff;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for(auto&amp;&amp; frame: buff){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 frame*=3D0.5;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 output&lt;&lt;buff;
<br>&gt; =C2=A0 =C2=A0 });//dsp object
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 //version 2: have context passed as argument
<br>&gt; =C2=A0 =C2=A0 std::astream_process&lt;float&gt; proc2(ctx,[](std::=
iastream const&amp; input,
<br>&gt; std::oastream&amp; output,std::audio_context&lt;<wbr>float&gt; con=
st&amp; context){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;float&gt;&amp; bu=
ff =3D ctx.borrow_buffer();
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 input&gt;&gt;buff;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for(auto&amp;&amp; frame: buff){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 frame*=3D2.0;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 output&lt;&lt;buff;
<br>&gt; =C2=A0 =C2=A0 });
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::process_group&lt;float&gt; pgroup;//a group of =
processes that will happen
<br>&gt; consecutivley
<br>&gt; =C2=A0 =C2=A0 pgroup.push(proc1);//add to group
<br>&gt; =C2=A0 =C2=A0 pgroup.push(proc2);//add to group
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 //configure stream relationships in terms of std::ai=
n / std:aout
<br>&gt; manually
<br>&gt; =C2=A0 =C2=A0 //std::ain/std::aout are std::astream globals that r=
efer to the default
<br>&gt; audio inputs and outputs supplied by the context in use
<br>&gt; =C2=A0 =C2=A0 //std::ain/std::aout will route the audio to the enp=
oint specified by
<br>&gt; the context reference held by the process that is streaming the da=
ta
<br>&gt; =C2=A0 =C2=A0 std::aout&lt;&lt;proc1&lt;&lt;proc2&lt;&lt;std::<wbr=
>ain;//method 1
<br>&gt; =C2=A0 =C2=A0 //std::ain&gt;&gt;proc2&gt;&gt;proc1&gt;&gt;std:<wbr=
>:aout;//method 2
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 pgroup.start();
<br>&gt; =C2=A0 =C2=A0 //do other stuff
<br>&gt; =C2=A0 =C2=A0 pgroup.stop();
<br>&gt;
<br>&gt; }
<br>&gt;
<br>&gt;
<br>&gt; //std::audio example 3 &quot;audio files&quot;
<br>&gt; void example_3(){
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::audio_context&lt;float&gt; ctx;
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::astream_process&lt;float&gt; proc(ctx,[](std::i=
afstream const&amp; input,
<br>&gt; std::oafstream&amp; output){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;float&gt;&amp; bu=
ff =3D ctx.borrow_buffer();
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 input&gt;&gt;buff;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for(auto&amp;&amp; frame: buff){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 frame=3D0.0;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 output&lt;&lt;buff;
<br>&gt; =C2=A0 =C2=A0 });//dsp object
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::iafstream audio_file1(ctx,&quot;filename1.<wbr>=
extension&quot;);//an audio file
<br>&gt; handle
<br>&gt; =C2=A0 =C2=A0 std::oafstream audio_file2(ctx,&quot;filename2.<wbr>=
extension&quot;);//an audio file
<br>&gt; handle
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 //routing
<br>&gt; =C2=A0 =C2=A0 audio_file2&lt;&lt;proc&lt;&lt;audio_<wbr>file1;//ta=
ke input from file nad write to file
<br>&gt; =C2=A0 =C2=A0 //audio_file1&gt;&gt;proc&gt;&gt;audio_<wbr>file2;//=
equivilent syntax
<br>&gt; =C2=A0 =C2=A0 proc.start();
<br>&gt; =C2=A0 =C2=A0 //do other stuff
<br>&gt; =C2=A0 =C2=A0 proc.stop();
<br>&gt; }
<br>&gt;
<br>&gt;
<br>&gt; //std::audio example 4 &quot;combination routing&quot;
<br>&gt; void example_3(){
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::audio_context&lt;float&gt; ctx;
<br>&gt; =C2=A0 =C2=A0 //manually select hardware endpoints
<br>&gt; =C2=A0 =C2=A0 std::size_t device_id =3D ctx.default_device_id();
<br>&gt; =C2=A0 =C2=A0 std::iastream input_device =3D
<br>&gt; ctx.get_device&lt;std::input_<wbr>device&gt;(device_id);
<br>&gt; =C2=A0 =C2=A0 std::oastream output_device =3D
<br>&gt; ctx.get_device&lt;std::output_<wbr>device&gt;(device_id);
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::astream_process&lt;float&gt; proc(ctx,[](std::i=
astream const&amp; input,
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 std::oastream&amp; output,
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 std::iafstream const&amp;
<br>&gt; input_file,
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0std::oafstream&amp; output_file){
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;float&gt;&amp; bu=
ff =3D ctx.borrow_buffer();
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 (input + input_file)&gt;&gt;buff;//add=
 streams to perform sum before
<br>&gt; writing to buffer
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //or you could use seperate buffers
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //like this
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;flo=
at&gt; buff1;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::frame_buffer&lt;flo=
at&gt; buff2;
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 input&gt;&gt;buff1;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 input_file&gt;&gt;buff2;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 buff1+=3Dbuff2;//buffer =
arithmatic
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 */
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 output&lt;&lt;buff;//send the contents=
 of buff to the hardware out and the
<br>&gt; file out
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 output_file&lt;&lt;buff;
<br>&gt; =C2=A0 =C2=A0 });
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 std::iafstream audio_file1(ctx,&quot;filename1.<wbr>=
extension&quot;);//the actual files
<br>&gt; to be used above
<br>&gt; =C2=A0 =C2=A0 std::oafstream audio_file2(ctx,&quot;filename2.<wbr>=
extension&quot;);
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 //connect the files to the process
<br>&gt; =C2=A0 =C2=A0 //connect the hardware device to the process
<br>&gt; =C2=A0 =C2=A0 audio_file2&lt;&lt;proc&lt;&lt;audio_<wbr>file1;//ta=
ke input from file
<br>&gt; =C2=A0 =C2=A0 output_device&lt;&lt;proc&lt;&lt;input_<wbr>device;/=
/also take from hardware
<br>&gt; =C2=A0 =C2=A0 proc.start();
<br>&gt; =C2=A0 =C2=A0 //do other stuff
<br>&gt; =C2=A0 =C2=A0 proc.stop();
<br>&gt; }
<br>&gt;
<br>&gt;
<br>&gt;
<br>&gt; REQUIRED LIBRARY MEMBERS
<br>&gt;
<br>&gt;
<br>&gt; namespace std{
<br>&gt; =C2=A0 =C2=A0 inline namespace audio{
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //working context for audio flow
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 template&lt;typename&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class audio_context;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 *The context in which all audio data i=
s centered.
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 *Contains: sampling rate, buffer size,=
 frame size, etc...
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 *The values of ain,aout,afin,afout ref=
er to the endpoints defined by
<br>&gt; the context, when applied to routing on a porocess tied to the con=
text
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 *think of a context as the program lev=
el driver object
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 */
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //audio streams (think like std::fstre=
am and its friends)
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class astream;//audio stream
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class oastream;//output audio stream
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class iastream;//input audio stream
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class oafstream;//output audio file st=
ream
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class iafstream;//input audio file str=
eam
<br>&gt;
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //stream endpoints
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class ain;//audio input endpoint
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class aout;//audio output endpoint
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class afin;//audio file input endpoint
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class afout//audio file output endpoin=
t
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //stream processing
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 template&lt;typename&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class astream_process;//a dsp process =
applied to a stream
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 template&lt;typename&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class process_group;//a group of proce=
sses that will act as one
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //containers
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 template&lt;typename&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class frame_buffer;//a sequence contai=
ner that is resizeable at
<br>&gt; runtime, but only with explicit resize calls. contains frames(see =
below)
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 /*Implementation note on frame_buffer
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*frame_buffer is intended to hol=
d N number of frames which
<br>&gt; themselves can hold M number of samples
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*meaning that the total size in =
samples if frame_buffer =3D N * M
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*ideally frame_buffers represent=
ation of its sample data will be
<br>&gt; continuous in memory
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 */
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 template&lt;typename&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class frame;//a container that holds s=
amples, thin array wrapper
<br>&gt;
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 //hardware representation
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class device;//an audio device as reco=
gnized by the OS
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class input_device;//an input device
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 class output_device;//an output device
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 // audio file formats
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 enum class afformat{
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raw,//raw headerless aud=
io bytes, interpreted only by the
<br>&gt; settings of the context.
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 //best used for temporar=
y storage within the life of a context
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 wav,
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 flac//etc...
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
<br>&gt; =C2=A0 =C2=A0 }
<br>&gt; }
<br>&gt;
<br>&gt;
<br>&gt;
<br>&gt; --
<br>&gt; You received this message because you are subscribed to the Google=
 Groups
<br>&gt; &quot;ISO C++ Standard - Future Proposals&quot; group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, =
send an
<br>&gt; email to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"xwvxNJ1UAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;ja=
vascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;r=
eturn true;">std-proposal...@<wbr>isocpp.org</a>.
<br>&gt; To post to this group, send email to <a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"xwvxNJ1UAQAJ" rel=3D"nofollow" onmous=
edown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.
<br>&gt; To view this discussion on the web visit
<br>&gt; <a href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-prop=
osals/f490fd21-cf07-4d7b-8936-c71c97a1ab9d%40isocpp.org" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/f490fd21-cf07-4d7b-8936-c71c97a1ab9d%40i=
socpp.org&#39;;return true;" onclick=3D"this.href=3D&#39;https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/f490fd21-cf07-4d7b-8936-c71c97a1=
ab9d%40isocpp.org&#39;;return true;">https://groups.google.com/a/<wbr>isocp=
p.org/d/msgid/std-<wbr>proposals/f490fd21-cf07-4d7b-<wbr>8936-c71c97a1ab9d%=
40isocpp.org</a><wbr>.
<br></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/01f6b6a7-2b1e-491a-a676-5fc8ad816aab%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/01f6b6a7-2b1e-491a-a676-5fc8ad816aab=
%40isocpp.org</a>.<br />

------=_Part_3420_2002602399.1465079056460--

------=_Part_3419_1679322864.1465079056460--

.
