Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - drmoth

Pages: [1]
1
Audio / Real-Time Synthesis?
« on: February 18, 2010, 11:22:36 am »
Hi, then I would recommend OpenFrameworks www.openframeworks.cc
It's Processing for C++ basically, so more complex but with the advantages of C++. There's support for 3D audio and sample playback (using FMOD and OpenAL) but it also supports real-time audio synthesis through RtAudio and also PortAudio. People have already hooked it up to Supercollider using OSC...

You might also want to look at the Synthesis Toolkit STK...

2
Audio / Spatialization and sound channels
« on: November 28, 2009, 07:05:07 pm »
Hi,

my class is here:
http://www.digitalstar.net/openframeworks/SoundStereo.zip

I use it in a different framework than SFML but the only thing that's different is the namespace I think.

In order to get stereo panning I have to set up the audio device like this in AudioDevice.cpp:
Code: [Select]

////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
AudioDevice::AudioDevice() :
myRefCount(0)
{
    float listenerDepth = 0.1;

    // Create the device
    myDevice = alcOpenDevice(NULL);

    if (myDevice)
    {
        // Create the context
        myContext = alcCreateContext(myDevice, NULL);

        if (myContext)
        {
            // Set the context as the current one (we'll only need one)
            alcMakeContextCurrent(myContext);

            // Initialize the listener
            Listener::SetPosition(0,0,listenerDepth);
            Listener::SetTarget(0,0,-listenerDepth);
        }
        else
        {
            std::cerr << "Failed to create the audio context" << std::endl;
        }
    }
    else
    {
        std::cerr << "Failed to open the audio device" << std::endl;
    }

}


The most important part of the above is this:
Code: [Select]
Listener::SetPosition(0,0,listenerDepth);
Listener::SetTarget(0,0,-listenerDepth);

3
Audio / Spatialization and sound channels
« on: November 28, 2009, 03:19:56 pm »
You can technically spatialize a stereo sound in 3D, but you have to split it into 2 mono channels, and then decide what distance to apart to space them.

I recently created a "stereo sound" class which just holds the left and right channel data as mono sounds. I used it to be able to pan stereo sounds, but you could also use it I guess to move stereo sounds around in 3d space. If you're interested I could post the code.

4
Audio / Threading questions for audio
« on: November 18, 2009, 02:12:53 pm »
Yeah I don't normally use global variables, just trying to find an equivalent example (which I guess isn't that equivalent).

I suppose my confusion comes from somehow in the past receiving a "double delete" error on exit when trying to delete member objects created using new()...but maybe I'm just confused :)

anyway problem solved.

5
Audio / Threading questions for audio
« on: November 18, 2009, 01:29:29 pm »
Well, unfortunately it's a little difficult to give you a working example because of the framework I'm using, but basically I found a workaround, sort of.

I don't get this error if I declare

Code: [Select]
Music myMusic;
and don't create the object in setup using new().

Also if I use the pointer version, I don't get the problem if I explicitly delete the pointer on exit, i.e.
Code: [Select]
delete myMusic

However I thought that explicitly deleting an object was necessary only if it was created on the stack, and not as a member of a class...but maybe I'm confused about this, or maybe the problem is elsewhere and this is just a symptom.

I was able to recreate this error I think in the Sound.cpp sample from SFML by creating a global variable called sf::Music* Music and then not deleting it. Is this just a gap in my C++ knowledge?  Somehow I thought that a class member object variable would call it's own destructor on exit.

6
Audio / Threading questions for audio
« on: November 18, 2009, 10:21:21 am »
Hi,

I'm usng version 1.5 from source (not svn).
The music is kept as a public pointer in my application class, and in my setup code I do this:

Code: [Select]
   myMusic = new Music();
    // Load an ogg music file
    if (!myMusic->OpenFromFile("data/bells.ogg"))
        return;

    myMusic->SetLoop(true);
    myMusic->Play();


Then, once I exit the application, if I haven't manually stopped the music by calling
Code: [Select]
myMusic->Stop();
just before the class holding the music pointer gets destroyed then I get a number of openal errors from the thread:

Quote
An internal OpenAL call failed in Sound.cpp (332) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state
An internal OpenAL call failed in SoundStream.cpp (221) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state
An internal OpenAL call failed in SoundStream.cpp (227) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state
An internal OpenAL call failed in SoundStream.cpp (239) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state
AL lib: ALc.c:1650: alcCloseDevice(): deleting 4 Buffer(s)
ofxSoundPlayerExample_debug: /home/blah/code/audio/openal-soft-1.10.622/OpenAL32/Include/alMain.h:54: EnterCriticalSection: Assertion `ret == 0' failed.
Aborted


Does that make sense?

7
Audio / Minor streaming-looping bug
« on: November 18, 2009, 02:41:15 am »
I've found a minor bug which is really not important, but I thought I'd flag it anyway..

If the file size of streaming (music) audio is less than the streaming chunk size then looping is ignored and playback always stops after the sound is played.

I believe this is due to
bool RequestStop = FillQueue();
which will return true in this case before entering the while-loop in SoundStream::Run()

Understandably streaming audio should never be this short (it defeats the purpose of streaming!), but it would be nice to have consistent behaviour if possible :)

thanks

8
Audio / Threading questions for audio
« on: November 18, 2009, 01:46:59 am »
Hi,

I've recently been using the Audio subsystem of SFML in a separate project. It's been really easy to integrate and the code is super clean, highly appreciated :)

However I have a couple of questions...

First of all when I quit my app (not an SFML app by the way) the OpenAL context is destroyed before the streaming music I'm playing is stopped, so I get a number of OpenAL errors from the thread that's still running (until it aborts).

If I stop the stream manually before exiting, this is fine, but I was wondering is there was an automatic way to do this? (i.e. making sure any music streams are stopped before stopping openal)

Second of all, I see that the music streams are threaded, but in my code the sample playback isn't. However I read in another post in this forum  that the entire audio system is threaded. Is that correct? I am I missing some SFML code that does this?

thanks!
Pierre

9
Audio / Piano fast in windows, slow in linux?
« on: November 18, 2009, 01:37:27 am »
Hi,

I've recently been running the Linux version of the audio subsystem of SFML and it works fine. The latency with the latest version of OpenAL Soft is really very good under Alsa (I have a crappy integrated laptop sound card).

You can tweak the buffer size of the OpenAL Soft driver in a config file in order to improve latency. Download the OpenAL Soft source package and read the contents of the alsoft.conf file.

If you have really large latencies you are possibly running OpenAL under pulseaudio.

Latencies in audio occur under Linux when your audio is not set up properly. There's a good guide to lowering latencies of audio under Linux that comes with the demo of Pianoteq (http://www.pianoteq.com/)

Pages: [1]