220 26136 <68BBAF0D-27AD-4D2E-8F95-47644F5A1382@gmail.com> article
Path: news.gmane.org!not-for-mail
From: alexander.zywicki@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Any interest to adding audio support to the std library?
Date: Fri, 3 Jun 2016 11:35:04 -0500
Lines: 311
Approved: news@gmane.org
Message-ID: <68BBAF0D-27AD-4D2E-8F95-47644F5A1382@gmail.com>
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 (1.0)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1464971838 11452 80.91.229.3 (3 Jun 2016 16:37:18 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 3 Jun 2016 16:37:18 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCS7TY6DTQOBBOXDY25AKGQECEZ4E2A@isocpp.org Fri Jun 03 18:37:13 2016
Return-path: <std-proposals+bncBCS7TY6DTQOBBOXDY25AKGQECEZ4E2A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f199.google.com ([209.85.161.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCS7TY6DTQOBBOXDY25AKGQECEZ4E2A@isocpp.org>)
	id 1b8s41-00086n-Ki
	for gclcip-std-proposals@m.gmane.org; Fri, 03 Jun 2016 18:35:13 +0200
Original-Received: by mail-yw0-f199.google.com with SMTP id y6sf227428080ywe.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 03 Jun 2016 09:35:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:subject:from:in-reply-to:date
         :content-transfer-encoding:message-id:references:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=+P7b/ccJ1wyJBinLI6ZgiJhL77XOwaWvO4HzT3InsSA=;
        b=rkIOf7wBJxULEFhBkombGJHp/VEkAm9CbuKEaE0w4nkoTtjy6FY92/D5MnJXIPJYOY
         X/GyYvKHlY6WUoYwI5k7OWeThZEqMgqdtXzSwhjfm6pd9Ee1/TAO9e/yl2VDRKNF4KGP
         n97sR8xzH8GTsnoQNspI5TlqmAfWf+JHCL2atMti4PycY8yZO9CfsIl8QSCV0ti1ObWe
         /LqjSApUJUWrr7/HRj8vdboCbt7zVoLMZCNnBT1vSNKnsaXT3FoF+u16Z7GPmXSxvfHW
         sAn8k/9+wwXXhE73lgyS3dYWpsEyHyLPRoF+1V0iynJ3zOjUoUVmet0eRQ3a71zGjbZt
         Veyw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:subject:from:in-reply-to:date
         :content-transfer-encoding:message-id:references:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=+P7b/ccJ1wyJBinLI6ZgiJhL77XOwaWvO4HzT3InsSA=;
        b=gDI5VhSJWT5ud9zTvU3r0fp1kXvKugFy6aa7g03jheukI37Ik14g7Mg0T+SuNaSiO+
         GGX5R9kb9yPEzkpEGg7BX1zbzrqJgeRypA0xjHUisWntlOhwWfslOD3h4KOO7ZXiI+z7
         5iGpEGQeYhk3yOLEut4RHhylCeBmY8MMF0gjhE8OaeNjOfywu6WSzzKkkOCMEksRQate
         LFmZyjWtCf3xZo1wEeKg1OB6Kd5KRJKGSlYcrU06Ca2Qoq6S1y1V4Cvpo0Q9jIS6yhEb
         0TD9AOzbQdPbKCA7YNnTFiUelLmEA5Hgu2n5Qf0s3JIpSnSoMmkVb6Wn8zXiREcA2Kpl
         nW/ 
X-Gm-Message-State: ALyK8tLnHzEjfZEMnLC+csfhg+gyHi3EfJ1/nKQ4DL5j/8922LTCjPF4cjxLexdlG0KYig==
X-Received: by 10.129.109.150 with SMTP id i144mr3175993ywc.30.1464971707755;
        Fri, 03 Jun 2016 09:35:07 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.13.210 with SMTP id 201ls405819ion.15.gmail; Fri, 03 Jun
 2016 09:35:06 -0700 (PDT)
X-Received: by 10.36.105.71 with SMTP id e68mr655774itc.77.1464971706708;
        Fri, 03 Jun 2016 09:35:06 -0700 (PDT)
Original-Received: from mail-it0-x22b.google.com (mail-it0-x22b.google.com. [2607:f8b0:4001:c0b::22b])
        by mx.google.com with ESMTPS id a12si464516itb.5.2016.06.03.09.35.06
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 03 Jun 2016 09:35:06 -0700 (PDT)
Received-SPF: pass (google.com: domain of alexander.zywicki@gmail.com designates 2607:f8b0:4001:c0b::22b as permitted sender) client-ip=2607:f8b0:4001:c0b::22b;
Original-Received: by mail-it0-x22b.google.com with SMTP id i127so2645127ita.1
        for <std-proposals@isocpp.org>; Fri, 03 Jun 2016 09:35:06 -0700 (PDT)
X-Received: by 10.36.254.199 with SMTP id w190mr731760ith.24.1464971706367;
        Fri, 03 Jun 2016 09:35:06 -0700 (PDT)
Original-Received: from [10.226.99.32] ([166.175.184.146])
        by smtp.gmail.com with ESMTPSA id d74sm154551ith.13.2016.06.03.09.35.05
        (version=TLSv1/SSLv3 cipher=OTHER);
        Fri, 03 Jun 2016 09:35:05 -0700 (PDT)
X-Mailer: iPhone Mail (13E238)
In-Reply-To: <CANh-dX=R4Oa0OPZSrL7c9PXGyAdvM2CCBdP9C+h--N4Vt-J=9g@mail.gmail.com>
X-Original-Sender: alexander.zywicki@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 alexander.zywicki@gmail.com designates 2607:f8b0:4001:c0b::22b as permitted
 sender) smtp.mailfrom=alexander.zywicki@gmail.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=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:26136
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26136>

Not currently, I am trying to gather syntactical usage, library feature ide=
as and design considerations so that I may implement a version of this that=
 is more complete than what I present here. I understand that something lik=
e this is most likely only to be considered if it is in common practice or =
use, unfortunately=20
I have not found an audio library based off of modern C++. Most of the ones=
 I know well are either pure C or very thin wrappers over an existing C lib=
rary. My goal is to create a library with becoming a standard down the line=
 in sight, but allow it to become mature enough for possible standardizatio=
n.
> On Jun 3, 2016, at 10:43 AM, 'Jeffrey Yasskin' via ISO C++ Standard - Fut=
ure Proposals <std-proposals@isocpp.org> wrote:
>=20
> 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.
>=20
>> On Fri, Jun 3, 2016 at 2:37 AM,  <alexander.zywicki@gmail.com> wrote:
>> I have drafted some ideas on how I think the c++ std library could suppo=
rt
>> audio functionality.
>>=20
>> I know that audio functionality is a very operating specific problem, bu=
t
>> with the recent trend towards implementing a file-system library and
>> possibly a graphics library I believe that audio would not be too much o=
f a
>> reach anymore.
>>=20
>> 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 th=
e
>> given examples.
>>=20
>> Please keep in mind my drafts are still very rough.
>>=20
>>=20
>> CODE EXAMPLES
>>=20
>> //std::audio example 1 "single process"
>> void example_1(){
>>    double sample_rate =3D 44100;
>>    std::size_t frame_size =3D2;
>>    std::size_t buffer_size=3D128;
>>=20
>>    std::audio_context<float>
>> ctx{sample_rate,buffer_size,frame_size};//contruct from values
>>=20
>>    std::astream_process<float> proc(ctx,[](std::iastream const& input,
>> std::oastream& output){
>>        std::frame_buffer<float>& buff =3D 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=3D0.0;//do something with audio
>>        }
>>        output<<buff;//stream to output
>>    });//dsp object
>>    //uses implied routing equivilent to
>>    //std::aout<<proc<<std::ain;
>>    //
>>=20
>>    proc.start();
>>    //do other stuff
>>    proc.stop();
>> }
>>=20
>> //std::audio example 2 "process group"
>> void example_2(){
>>=20
>>    std::audio_context<float> ctx;//default context created with
>> std::default_* values
>>=20
>>    //version 1: capture context via lambda
>>    std::astream_process<float> proc1(ctx,[&ctx](std::iastream const& inp=
ut,
>> std::oastream& output){
>>        std::frame_buffer<float>& buff =3D ctx.borrow_buffer();
>>        input>>buff;
>>        for(auto&& frame: buff){
>>            frame*=3D0.5;
>>        }
>>        output<<buff;
>>    });//dsp object
>>=20
>>    //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 =3D ctx.borrow_buffer();
>>        input>>buff;
>>        for(auto&& frame: buff){
>>            frame*=3D2.0;
>>        }
>>        output<<buff;
>>    });
>>=20
>>    std::process_group<float> pgroup;//a group of processes that will hap=
pen
>> consecutivley
>>    pgroup.push(proc1);//add to group
>>    pgroup.push(proc2);//add to group
>>=20
>>    //configure stream relationships in terms of std::ain / std:aout
>> manually
>>    //std::ain/std::aout are std::astream globals that refer to the defau=
lt
>> 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
>>=20
>>    pgroup.start();
>>    //do other stuff
>>    pgroup.stop();
>>=20
>> }
>>=20
>>=20
>> //std::audio example 3 "audio files"
>> void example_3(){
>>=20
>>    std::audio_context<float> ctx;
>>=20
>>    std::astream_process<float> proc(ctx,[](std::iafstream const& input,
>> std::oafstream& output){
>>        std::frame_buffer<float>& buff =3D ctx.borrow_buffer();
>>        input>>buff;
>>        for(auto&& frame: buff){
>>            frame=3D0.0;
>>        }
>>        output<<buff;
>>    });//dsp object
>>=20
>>    std::iafstream audio_file1(ctx,"filename1.extension");//an audio file
>> handle
>>    std::oafstream audio_file2(ctx,"filename2.extension");//an audio file
>> handle
>>=20
>>    //routing
>>    audio_file2<<proc<<audio_file1;//take input from file nad write to fi=
le
>>    //audio_file1>>proc>>audio_file2;//equivilent syntax
>>    proc.start();
>>    //do other stuff
>>    proc.stop();
>> }
>>=20
>>=20
>> //std::audio example 4 "combination routing"
>> void example_3(){
>>=20
>>    std::audio_context<float> ctx;
>>    //manually select hardware endpoints
>>    std::size_t device_id =3D ctx.default_device_id();
>>    std::iastream input_device =3D
>> ctx.get_device<std::input_device>(device_id);
>>    std::oastream output_device =3D
>> ctx.get_device<std::output_device>(device_id);
>>=20
>>    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 =3D 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;
>>=20
>>            input>>buff1;
>>            input_file>>buff2;
>>            buff1+=3Dbuff2;//buffer arithmatic
>>        */
>>        output<<buff;//send the contents of buff to the hardware out and =
the
>> file out
>>        output_file<<buff;
>>    });
>>=20
>>    std::iafstream audio_file1(ctx,"filename1.extension");//the actual fi=
les
>> to be used above
>>    std::oafstream audio_file2(ctx,"filename2.extension");
>>=20
>>    //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();
>> }
>>=20
>>=20
>>=20
>> REQUIRED LIBRARY MEMBERS
>>=20
>>=20
>> 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
>>        */
>>=20
>>        //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
>>=20
>>=20
>>        //stream endpoints
>>        class ain;//audio input endpoint
>>        class aout;//audio output endpoint
>>        class afin;//audio file input endpoint
>>        class afout//audio file output endpoint
>>=20
>>        //stream processing
>>        template<typename>
>>        class astream_process;//a dsp process applied to a stream
>>=20
>>        template<typename>
>>        class process_group;//a group of processes that will act as one
>>=20
>>        //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 =3D N * =
M
>>         *ideally frame_buffers representation of its sample data will be
>> continuous in memory
>>        */
>>=20
>>        template<typename>
>>        class frame;//a container that holds samples, thin array wrapper
>>=20
>>=20
>>        //hardware representation
>>        class device;//an audio device as recognized by the OS
>>        class input_device;//an input device
>>        class output_device;//an output device
>>=20
>>        // 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 contex=
t
>>            wav,
>>            flac//etc...
>>        }
>>    }
>> }
>>=20
>>=20
>>=20
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/f490fd21-cf=
07-4d7b-8936-c71c97a1ab9d%40isocpp.org.
>=20
> --=20
> You received this message because you are subscribed to a topic in the Go=
ogle Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.=
org/d/topic/std-proposals/Hkdh02Ejx6s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to std-p=
roposals+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/isoc=
pp.org/d/msgid/std-proposals/CANh-dX%3DR4Oa0OPZSrL7c9PXGyAdvM2CCBdP9C%2Bh--=
N4Vt-J%3D9g%40mail.gmail.com.

--=20
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 e=
mail 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/68BBAF0D-27AD-4D2E-8F95-47644F5A1382%40gmail.com=
..

.
