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 - Rock_Hardbuns

Pages: [1]
1
Audio / sf::Sound destructor crash
« on: November 10, 2010, 10:43:16 pm »
Well, it's a memory error. Could be a simple array index thing.

Could be an allocation thing. Does it happen if you go
Code: [Select]

sf::Sound* snd = new sf::Sound();
snd->GetStatus(); // don't let it optimize out!
delete snd;
return 0;

2
Audio / incorrect documentation of Sound::SetRelativeToListener!
« on: November 07, 2010, 12:12:54 pm »
The sound is always relative (in relation) to the listener, or there wouldn't be a sound.
What you are discussing is whether the sound is fixed relative to the listener or dynamic relative to the listener.

 :D

3
SFML website / Improve the search please?
« on: November 01, 2010, 09:39:14 pm »
phpBB search usually defaults  to an OR relationship. So if you search for "Car wheel" it gives you every post that has car OR wheel in it.

The option to search for "all the terms" should ideally change this to an AND relationship, but it doesn't always work!

Best way to go about it is to simply type out the booleans. Like "AND Car AND wheel".

4
Audio / Is it necessary to use OpenAL and libSndFile?
« on: October 31, 2010, 02:01:35 pm »
Oh, now it makes sense!

Well, no. I have no idea what you are saying. :D

Just stick to dynamic linking using the stock binary of the lib and there is no problem.

5
Audio / Is it necessary to use OpenAL and libSndFile?
« on: October 30, 2010, 11:55:09 am »
You can certainly make proprietary software with LGPL libs. You just can't hijack the lib and make it your property.

I know the LGPL is pretty hard to read, so here is  a rundown:

If you link dynamically to the lib and do not distribute the DLL/SO file, you are not covered by the license at all. Because you are not touching the lib in any legally binding way.

EDIT:
If you link dynamically to the lib and do distribute the DLL/SO file, you are under license. You do not have supply the source to your own software. You only have to alert users to the using of the lib and it's license in your credits/copyright blurbs.
/EDIT

If you link statically, you have to supply the object code to your software so that it can be rebuilt against new versions of the Lib. You do not have to supply the source code to your software, but you do have to supply it for the lib itself.

This is assuming that you don't modify the lib code or include more of it than is required to use the lib. At that point things get messy.

Edit > It appears I was wrong about the redistribution of unmodified binaries. It's ok to do, as long as you let the users know what it is they are getting.

6
Audio / Basic effect generator
« on: October 29, 2010, 10:24:43 pm »
Quote from: "Svenstaro"
Nice! You should put it on the wiki, too. What's the license on it, btw?


Public domain.

I haven't tried to figure the wiki out yet, but if someone else want to post it, that's fine with me.

7
Audio / Basic effect generator
« on: October 29, 2010, 08:03:10 pm »
I made a rudimentary effect synthesizer and sound manager. It's convenient for arcade type games and such. The sound is deliberately a bit distorted, for a little retro vibe.

main.cpp
Code: [Select]

#include <SFML/System.hpp>

#include "soundMan.hpp"



int main(int argc, char** argv)
{

SoundMan* sm = new SoundMan();
int boom = sm->createNoise( 80000, 0.4f, 0.1f, true);
int bam = sm->createNoise( 15000, 1.0f, 1.0f, true);
int zap = sm->createNoise( 5000, 0.0f, 1.0f, false);

int pew = sm->createBeep( 5000, 2000.0f, 50.0f, 0.0f, 0.0f, true);
int alien1 = sm->createBeep( 100000, 2000.0f, 50.0f, 0.5f, 0.9f, true);
int alien2 = sm->createBeep( 100000, 20.0f, 1500.0f, 1.0f, 1.0f, true);
int bigFail = sm->createBeep( 100000, 500.0f, 50.0f, 0.1f, 0.4f, true);

sm->playSound(boom);
sf::Sleep(0.5f);
sm->playSound(bam);
sf::Sleep(0.5f);
sm->playSound(zap);

sf::Sleep(0.5f);
sm->playSound(pew);
sf::Sleep(0.5f);
sm->playSound(alien1);
sf::Sleep(0.5f);
sm->playSound(alien2);
sf::Sleep(0.5f);
sm->playSound(bigFail);
return 0;
}


soundMan.hpp
Code: [Select]

#pragma once
#include <vector>
#include <cmath>
#include <cstdio>
#include <SFML/Audio.hpp>

class SoundMan
{
private:
std::vector<sf::Sound*> playerVec;
std::vector<sf::SoundBuffer*> soundBufVec;

unsigned int currentPlayer;

inline float symClip(float Value, float Limit = 1.0f)
{
return ((fabsf(Value+Limit) - fabsf(Value-Limit)) * 0.5f);
}

public:
SoundMan();
~SoundMan();

void playSound(int index);

//assumes SR = 44100
//Frequencies given in Hz, for example start at 1000.0, end at 100
//Wobble is pitch modulation. Both depth and rate are in the 0.0 to 1.0 range
//A wobble depth of 0.0f turns it off.
int createBeep( int lengthInSamples, float startFrequency, float endFrequency,
float wobbleRate, float wobbleDepth, bool fadeOut);

//Lowpass parameters are in the 0.0 to 1.0 range. 1.0 means the filter is fully open.
int createNoise( int lengthInSamples, float lowPassStart, float lowPassEnd, bool fadeOut);

};


soundMan.cpp
Code: [Select]

#include "soundMan.hpp"


SoundMan::SoundMan()
{
playerVec.push_back( new sf::Sound() );
playerVec.push_back( new sf::Sound() );
playerVec.push_back( new sf::Sound() );
playerVec.push_back( new sf::Sound() );
playerVec.push_back( new sf::Sound() );
currentPlayer = 0;
}



SoundMan::~SoundMan()
{
while(!playerVec.empty())
{
delete playerVec.back();
playerVec.pop_back();
}

while(!soundBufVec.empty())
{
delete soundBufVec.back();
soundBufVec.pop_back();
}
playerVec.clear();
soundBufVec.clear();
}



void SoundMan::playSound(int index)
{
playerVec[currentPlayer]->Stop();
playerVec[currentPlayer]->SetBuffer( *(soundBufVec[index]) );
playerVec[currentPlayer]->Play();

currentPlayer++;
if(currentPlayer == playerVec.size()) currentPlayer = 0;
}



int SoundMan::createBeep( int lengthInSamples, float startFrequency, float endFrequency, float wobbleRate, float wobbleDepth, bool fadeOut)
{
sf::Int16 preBuffer[lengthInSamples];

const float p1 = startFrequency / 44100.0f;
const float p2 = endFrequency / 44100.0f;
float phase = 0.0f;

float wobPhase = 0.0f;

for(int i = 0; i < lengthInSamples; i++)
{
const float alpha = (float)i / (float)lengthInSamples;
const float p = p1 + alpha * (p2 - p1);
phase +=p;
if(phase > 1.0f) phase -= 1.0f;

wobPhase += (wobbleRate * 0.001f);
if(wobPhase > 1.0f) wobPhase -= 1.0f;
const float wob = sin( 2.0 * M_PI * wobPhase);

float tmp = sin( 2.0 * M_PI * (phase + wob * wobbleDepth));

tmp=tmp*tmp*tmp;
tmp = symClip(tmp, 0.6f);

if(fadeOut)
{
const float vol = 1.0f + alpha * -1.0f;
tmp = tmp * vol * vol;
}

preBuffer[i] = sf::Int16(tmp * 32767);
}

sf::SoundBuffer* sBuf = new sf::SoundBuffer();
sBuf->LoadFromSamples(preBuffer, lengthInSamples, 1, 44100);
soundBufVec.push_back(sBuf);
return soundBufVec.size() - 1;
}



int SoundMan::createNoise( int lengthInSamples, float lowPassStart, float lowPassEnd, bool fadeOut)
{
float buf1 = 0.0f;
float buf2 = 0.0f;

const float F1 = lowPassStart * 0.7f;
const float F2 = lowPassEnd * 0.7f;

sf::Int16 preBuffer[lengthInSamples];

for(int i = 0; i < lengthInSamples; i++)
{
float tmp = sf::Randomizer::Random(-0.9f, 0.9f);
const float alpha = (float)i / (float)lengthInSamples;
float F = F1 + alpha * (F2 - F1);
F = F * F * F;

buf1 += F * (tmp - buf1);
buf2 += F * (buf1 - buf2);

tmp = buf2;
tmp = tmp * (1.0f / F);
tmp = symClip(tmp, 0.6f);
if(fadeOut)
{
const float vol = 1.0f + alpha * -1.0f;
tmp = tmp * vol * vol;
}

preBuffer[i] = tmp * 32767;
}


sf::SoundBuffer* sBuf = new sf::SoundBuffer();
sBuf->LoadFromSamples(preBuffer, lengthInSamples, 1, 44100);
soundBufVec.push_back(sBuf);
return soundBufVec.size() - 1;
}



8
General / problem in using SFML in linux
« on: October 29, 2010, 06:06:01 pm »
The linker will need to be told what to do. Some IDEs have template projects and such that sets that stuff up (CodeBlocks maybe?), but you might as well get used to figuring that stuff out.

Link errors are difficult enough even when you know how it works.

9
General / problem in using SFML in linux
« on: October 29, 2010, 05:26:48 pm »
Undefined reference means that you are not linking to the libs properly.

I am not familiar with the IDEs you've tried (I just use a text editor), but they should have some place to add library names to the build settings.

10
Audio / Is it necessary to use OpenAL and libSndFile?
« on: October 28, 2010, 08:31:05 pm »
There's RTAudio which is simpler than portAudio, and under a more permissive license. However, like portAudio it's just low latency input/output streams.

What's the issue with LGPL though?

Pages: [1]