<div dir="ltr">How well would the storablevector package (Data.StorableVector) work for storing audio data? One of the major issues I&#39;m still working over is that I want to maintain something similar to a [[a]] format (since the underlying PortAudio library and hardware could support hundreds of interleaved channels) but I would like to be able to build in some typechecking to the functions to make sure the number of channels matches the nubmer expected in the functions. I&#39;ve considered doing the following:<br>
<br>&gt; data SingleChannel<br>&gt; data DualChannel<br>&gt; data TriChannel<br>&gt; type Frames = [[a]]<br><br>&gt; data AudioData a = AudioData Frames<br><br>&gt; adata = [[x] | x &lt;- [...]] :: AudioData SingleChannel<br>
<br>I&#39;d like to have a better way of:<br>1) packing the audio data in something other than a list<br>2) representing more information about the data parameters (such as sample rate and number of channels) without relying as heavily upon runtime checks/errors (which HCodecs Data.Audio format seems to rely on).<br>
<br>The ideal format would be [(a,a,..a)], but this seems cumbersome (since each tuple would have to be defined individually),<br><br>I&#39;m pretty sure that a runtime check on both sample rate, and number of channels will be necessary, but I just want to ask a little more before continuing down that path.<br>
<br>I also noticed that Data.Audio uses a DiffUArray. In this circumstance, would a StorableVector be better, or a DiffUArray?<br><br><br><div class="gmail_quote">On Sun, Aug 24, 2008 at 1:06 PM, Eric Kidd <span dir="ltr">&lt;<a href="mailto:haskell@randomhacks.net">haskell@randomhacks.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Sun, Aug 24, 2008 at 12:41 PM, John Van Enk &lt;<a href="mailto:vanenkj@gmail.com">vanenkj@gmail.com</a>&gt; wrote:<br>

&gt; It implements the Haskell bindings to the PortAudio library. This is the<br>
&gt; library behind Audacious. I *have not* implemented the callback model yet,<br>
&gt; but I plan to do that.<br>
&gt;<br>
&gt; Perhaps this will be something which is useful to you?<br>
<br>
</div>Looks like a great binding! We actually use portaudio in callback mode<br>
at work, with reasonable success (from C++).<br>
<br>
One question: I notice that your writeStream function represents audio<br>
using &#39;[[a]]&#39;.<br>
<br>
 &nbsp;writeStream :: (Storable a) =&gt; PaStream a -- ^ The output stream<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; [[a]] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-- ^ The samples to be played<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; Int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-- ^ Number of frames<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; IO (Either String ErrorCode) -- ^ The return status<br>
of the write<br>
<br>
In my experiments, I&#39;ve been somewhat unsatisfied with the performance<br>
of &#39;[[a]]&#39; as an audio format. Would you be interested in also<br>
supporting an array-based format for audio data?<br>
<br>
I&#39;m currently converting my program to use HCodec&#39;s Data.Audio<br>
representation, which looks pretty promising. I don&#39;t know how it<br>
performs yet, but I&#39;ll let you know.<br>
<br>
Thank you for the pointer to your library! It will make an excellent<br>
addition to the available Haskell sound libraries.<br>
<br>
Cheers,<br>
<font color="#888888">Eric<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>/jve<br>
</div>