www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D audio playing and analysis library?

reply "Gan" <avisaria me.com> writes:
I found this: https://github.com/p0nce/dplug

Which seems to be a good analysis library but I haven't found a 
library to play sounds.
Is there one?
Apr 28 2015
next sibling parent reply "Dragos Carp" <dragoscarp gmail.com> writes:
On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:
 I found this: https://github.com/p0nce/dplug

 Which seems to be a good analysis library but I haven't found a 
 library to play sounds.
 Is there one?
https://github.com/D-Programming-Deimos/portaudio
Apr 28 2015
parent reply "Gan" <avisaria me.com> writes:
On Tuesday, 28 April 2015 at 11:28:42 UTC, Dragos Carp wrote:
 On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:
 I found this: https://github.com/p0nce/dplug

 Which seems to be a good analysis library but I haven't found 
 a library to play sounds.
 Is there one?
https://github.com/D-Programming-Deimos/portaudio
Downloaded it, put the D example in a source folder, downloaded the official library, compiled the official library, stuck the libportaudio.la with the example, ran DUB and it can't the port audio library. Undefined symbols for architecture x86_64: "_Pa_CloseStream", referenced from: __Dmain in unknown.o The source is 3 years old, probably why no dub.json file. Know how to fix the library problem?
Apr 28 2015
next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 28 April 2015 at 13:43:02 UTC, Gan wrote:
 On Tuesday, 28 April 2015 at 11:28:42 UTC, Dragos Carp wrote:
 On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:
 I found this: https://github.com/p0nce/dplug

 Which seems to be a good analysis library but I haven't found 
 a library to play sounds.
 Is there one?
https://github.com/D-Programming-Deimos/portaudio
Downloaded it, put the D example in a source folder, downloaded the official library, compiled the official library, stuck the libportaudio.la with the example, ran DUB and it can't the port audio library. Undefined symbols for architecture x86_64: "_Pa_CloseStream", referenced from: __Dmain in unknown.o The source is 3 years old, probably why no dub.json file. Know how to fix the library problem?
What does dub -v show?
Apr 28 2015
prev sibling parent "Chris" <wendlec tcd.ie> writes:
On Tuesday, 28 April 2015 at 13:43:02 UTC, Gan wrote:
 On Tuesday, 28 April 2015 at 11:28:42 UTC, Dragos Carp wrote:
 On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:
 I found this: https://github.com/p0nce/dplug

 Which seems to be a good analysis library but I haven't found 
 a library to play sounds.
 Is there one?
https://github.com/D-Programming-Deimos/portaudio
Downloaded it, put the D example in a source folder, downloaded the official library, compiled the official library, stuck the libportaudio.la with the example, ran DUB and it can't the port audio library. Undefined symbols for architecture x86_64: "_Pa_CloseStream", referenced from: __Dmain in unknown.o The source is 3 years old, probably why no dub.json file. Know how to fix the library problem?
It should work, I'm using it a lot. I use libportaudio.a, make sure you reference deimos/portaudio.di or have it in your `source` folder. Here's an excerpt from my dub.json (you might have to include other libs too): "libs": [ "portaudio", "asound", "jack", "sndfile", "FLAC", "vorbisenc", "vorbis", "ogg" ], Also, compile or download the portaudio lib for x86_64, if you're on 64bit. Alternatively, compile your code with -m32. BTW, did you pass the library to the compiler and linker?
Apr 28 2015
prev sibling parent reply "ponce" <contact gam3sfrommars.fr> writes:
On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:
 I found this: https://github.com/p0nce/dplug

 Which seems to be a good analysis library but I haven't found a 
 library to play sounds.
 Is there one?
SDL2 can through DerelictSDL2 (use the mixer extension for easier playback). D-SFML can probably too. Out of Topic: we need what ae.utils.graphics does for images, but for sound! A good abstraction for audio data and processors would be welcome. Vanilla ranges do not cut it since it would need the additional concept of: - clearing the state (setting delaylines to 0) - separate channels that can be stored interleaved or not. Samples would be indexed by time and channel index. I feel like samplerate can be left out of the equation, it will almost always be a runtime value.
Apr 28 2015
next sibling parent reply "ponce" <contact gam3sfrommars.fr> writes:
On Tuesday, 28 April 2015 at 15:00:18 UTC, ponce wrote:
 - clearing the state (setting delaylines to 0)
 - separate channels that can be stored interleaved or not. 
 Samples would be indexed by time and channel index. I feel like 
 samplerate can be left out of the equation, it will almost 
 always be a runtime value.
- and more importantly, batch processing instead of sample per sample like I do now in dplug
Apr 28 2015
parent reply "Stincky gecko" <stig nowhere.fi> writes:
On Tuesday, 28 April 2015 at 15:01:23 UTC, ponce wrote:
 On Tuesday, 28 April 2015 at 15:00:18 UTC, ponce wrote:
 - clearing the state (setting delaylines to 0)
 - separate channels that can be stored interleaved or not. 
 Samples would be indexed by time and channel index. I feel 
 like samplerate can be left out of the equation, it will 
 almost always be a runtime value.
- and more importantly, batch processing instead of sample per sample like I do now in dplug
in d plug sample by sample processing is justified because of the z-transform, while in video games you just basically play some wavetables.
Apr 28 2015
parent reply "ponce" <contact gam3sfrommars.fr> writes:
On Tuesday, 28 April 2015 at 15:11:16 UTC, Stincky gecko wrote:
 On Tuesday, 28 April 2015 at 15:01:23 UTC, ponce wrote:
 On Tuesday, 28 April 2015 at 15:00:18 UTC, ponce wrote:
 - clearing the state (setting delaylines to 0)
 - separate channels that can be stored interleaved or not. 
 Samples would be indexed by time and channel index. I feel 
 like samplerate can be left out of the equation, it will 
 almost always be a runtime value.
- and more importantly, batch processing instead of sample per sample like I do now in dplug
in d plug sample by sample processing is justified because of the z-transform, while in video games you just basically play some wavetables.
Even hugely stateful things can benefit of buffering. For example, biquad filters have an internal loop that looks like (pseudo-code): for each sample { input <- input-signal[n] output <- a0 * input + a1 * x[0] + a2 * x[1] - a3 * y[0] - a4 * y[1] // update state of filter x[1] <- x[0] x[0] <- input y[1] <- y[0] y[0] <- output; } It cannot be parallelized because it's too stateful. BUT by unrolling it by 3, SIMD can be used and benefit such a loop.
Apr 28 2015
parent reply "Stincky gecko" <stinghjkl nowhere.fi> writes:
On Tuesday, 28 April 2015 at 15:49:53 UTC, ponce wrote:
 On Tuesday, 28 April 2015 at 15:11:16 UTC, Stincky gecko wrote:
 On Tuesday, 28 April 2015 at 15:01:23 UTC, ponce wrote:
 On Tuesday, 28 April 2015 at 15:00:18 UTC, ponce wrote:
 - clearing the state (setting delaylines to 0)
 - separate channels that can be stored interleaved or not. 
 Samples would be indexed by time and channel index. I feel 
 like samplerate can be left out of the equation, it will 
 almost always be a runtime value.
- and more importantly, batch processing instead of sample per sample like I do now in dplug
in d plug sample by sample processing is justified because of the z-transform, while in video games you just basically play some wavetables.
Even hugely stateful things can benefit of buffering. For example, biquad filters have an internal loop that looks like (pseudo-code): for each sample { input <- input-signal[n] output <- a0 * input + a1 * x[0] + a2 * x[1] - a3 * y[0] - a4 * y[1] // update state of filter x[1] <- x[0] x[0] <- input y[1] <- y[0] y[0] <- output; } It cannot be parallelized because it's too stateful. BUT by unrolling it by 3, SIMD can be used and benefit such a loop.
This is what i meant by z-transform, maybe a confusion in the name, but it think to "the fact that the previous sample value must be stored for processing the next one"... If you have only a filter it can be batch-processed but if the the filter is plugged to a delay line itself pluged to a SSB frequency shifter whose itself has a feedback bus going to...well it cant be buffered anymore. In video game, they play wavetables and eventually the output is passed in a binaural spatiializer or a reverb unit...though it's still need sample rate info for re-sampling and maybe dithering depending on the sample bit-depth of the samples frames.
Apr 28 2015
parent "ponce" <contact gam3sfrommars.fr> writes:
On Tuesday, 28 April 2015 at 17:50:48 UTC, Stincky gecko wrote:
 If you have only a filter it can be batch-processed but if the 
 the filter is plugged to a delay line itself pluged to a SSB 
 frequency shifter whose itself has a feedback bus going 
 to...well it cant be buffered anymore.
I see what you mean, but maybe it can be buffered. With ae.utils.graphics, even a long chain of operations still benefits from pixel being arranged in scanlines. It's like "expression templates for images" and maybe we need "expression templates for sound". The memory support for this is often alloca() in the C++ world. And it's pretty cumbersome to do everything with buffers.
 In video game, they play wavetables and eventually the output 
 is passed in a binaural spatiializer or a reverb unit...though 
 it's still need sample rate info for re-sampling and maybe 
 dithering depending on the sample bit-depth of the samples 
 frames.
Indeed wavetable look-up is not stateful.
Apr 29 2015
prev sibling parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
On 29/04/2015 3:00 a.m., ponce wrote:
 On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:
 I found this: https://github.com/p0nce/dplug

 Which seems to be a good analysis library but I haven't found a
 library to play sounds.
 Is there one?
SDL2 can through DerelictSDL2 (use the mixer extension for easier playback). D-SFML can probably too. Out of Topic: we need what ae.utils.graphics does for images, but for sound! A good abstraction for audio data and processors would be welcome. Vanilla ranges do not cut it since it would need the additional concept of: - clearing the state (setting delaylines to 0) - separate channels that can be stored interleaved or not. Samples would be indexed by time and channel index. I feel like samplerate can be left out of the equation, it will almost always be a runtime value.
I've seriously considered in the past to implement a library just like Devisualization.Window but for sound. Unfortunately my knowledge of sound/music isn't good enough to do so.
Apr 28 2015
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
idk if it would be useful at all, I'm not even happy with it 
myself yet, but I am writing a simpleaudio.d 
https://github.com/adamdruppe/arsd/blob/master/simpleaudio.d

it is meant to do waveform i/o and MIDI, but I'm not happy with 
my first draft of the api so it is probably going to change.... 
eventually.

Currently works on Windows (winMM) and Linux (ALSA).
Apr 28 2015
parent Rikki Cattermole <alphaglosined gmail.com> writes:
On 29/04/2015 3:27 a.m., Adam D. Ruppe wrote:
 idk if it would be useful at all, I'm not even happy with it myself yet,
 but I am writing a simpleaudio.d
 https://github.com/adamdruppe/arsd/blob/master/simpleaudio.d

 it is meant to do waveform i/o and MIDI, but I'm not happy with my first
 draft of the api so it is probably going to change.... eventually.

 Currently works on Windows (winMM) and Linux (ALSA).
I would be interested in having a chat with you about what we need long term to get a good audio playing library going. https://gitter.im/rikkimax
Apr 28 2015