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

Pages: [1]
1
Audio / Re: Cropping SoundBuffer
« on: March 31, 2014, 10:18:58 am »
What does "it just doest work" mean? Do you make sure that the referenced sound buffer is still valid when the sound is playing?
[/quote]

Well, while debugging, the value of the sound is
+               a       <Information not available, no symbols loaded for sfml-audio-2.dll>     sf::Sound
 

And what do you mean by checking if it i valid? I have no verfication implemented yet.


I thing the thing to do now is trying Laurent's code, maybe that solves my problem.

2
Audio / Re: Cropping SoundBuffer
« on: March 31, 2014, 09:40:22 am »
So, okay...

I have debugging and debugging, all the values of the arrays seem okay, but when i try to assign the SoundBuffer to a sound (
 sound.setBuffer(buffer)
) It just doest work.
Does really noone have any ideas?

You should show us how you call the function and create/play the sound.

And this would be much better:

void BufferHelper::RemoveFromBeginning(const sf::SoundBuffer src, sf::Sound§Buffer& dst)
{
    const std::size_t cut = 2205; // should rather be calculated from sample rate and channel count

    src.loadFromSamples(dst.getSamples() + cut, dst.getSampleCount() - cut, dst.channelCount(), dst.sampleRate());
}

Can you explain the syntax and meaning of
sf::Sound§Buffer& dst
?
I really have hope that this piece of code could solve my problem, but i just dont get this part :)

3
Audio / Re: Cropping SoundBuffer
« on: March 28, 2014, 12:44:43 pm »
You should show us how you call the function and create/play the sound.

And this would be much better:


Well, ok, the function will be a bit complicated, since i want the program to remember the part that was cut of, so it can be added back later! The way i wanted to do this by giving two arguments by reference - an array that would store the information and an integer which would count the times the piece is cut off. Can you maybe suggest a better solution?

About the channel count - it will always be only one channel, since all the sounds are recorded using SoundBufferRecorder.

I call the function like this -


sf::Sound s;
sf::SoundBuffer buf = RemoveFromBeginning(buffer1);
s.setBuffer(buf);
s.setLoop(true);
s.play();

 

4
Audio / Cropping SoundBuffer
« on: March 28, 2014, 11:48:34 am »
Hello SFML community!

So, i have a problem -

In a project that i am working on, there is a need to cut off a small part(1/20 sec) of the sound buffer from the beginning.

So essentially i made a function that takes the soundbuffer, removes the first 2205 (44100 / 20) samples and returns it. Then i make a sound from the returned buffer, but it wont play!
Is there any special tricks or things that i should know when doing these type of things?
Maybe there is a better way of doing this?

here is the function:

sf::SoundBuffer BufferHelper::RemoveFromBeginning(sf::SoundBuffer Buffer)
{
        const sf::Int16* Samples = Buffer.getSamples();

        std::vector<sf::Int16> vectorBufferNew;
        vectorBufferNew.reserve(Buffer.getSampleCount() - 2205);
        vectorBufferNew.resize(Buffer.getSampleCount() - 2205);

        for (int i = 0; i < Buffer.getSampleCount() - 2205; i++)
        {
                vectorBufferNew[i] = Samples[2205 + i];
        }

        sf::SoundBuffer FinalBuffer;
        FinalBuffer.loadFromSamples(&vectorBufferNew[0], vectorBufferNew.size(), 1, 44100);

        return FinalBuffer;
}
 

Thanks

5
Audio / Re: Combining recorded buffers.
« on: March 25, 2014, 01:40:19 pm »

You don't need to deal with stereo, just produce a mono buffer from your two mono buffers. Combine the samples one by one, and don't forget to pass "1" instead of "2" to the loadFromSamples function. Don't overcomplicate the task ;)


Thank you so much. I feel really dumb now. :D

ps. SFML has really great customer support apparently!!!

6
Audio / Re: Combining recorded buffers.
« on: March 25, 2014, 01:21:20 pm »
Maybe something about the number of channels? Recorded sounds are mono (1 channel), whereas the other example uses 2 channels.
Is there a way to go arround this? Like converting the mono buffer to a stereo?

So the array for a stereo buffer would be [s-left,s-right,s-left,s-right] ?

And mono? If it is just [s-mono,s-mono] couldnt i transform it into  [s-mono,s-mono-copy,s-mono,s-mono-copy] ?

Or am i understanding this completely wrong?

And what how does the size of the combined buffer relates to the size of the original ones? Is it half? twice? random?

Do you mean the file size?
I merged two recorded files. The file size of the two merged buffers is the same as the largest of the two.


ok, the SampleCount from the downloaded file is 93684 and the recorded one is  74970 although the recorded one is 2 seconds long but the downloaded is only 1 second long.

So, it must be the problem with the chanel count.


7
Audio / Re: Combining recorded buffers.
« on: March 25, 2014, 12:58:08 pm »
It doesn't change anything, SFML loads it in 16-bit samples.

I see... But can you explain what am i doing wrong with the newly recorded 16-bit sample Buffers?

How do they differ from the ones loaded from file?

8
Audio / Re: Combining recorded buffers.
« on: March 25, 2014, 12:41:59 pm »
Ok, i found out that the Sample .wav file i was using had 8bits per sample. And the .wav recorded using SoundBufferRecorded has 16bits per sample.

9
Audio / Combining recorded buffers.
« on: March 25, 2014, 12:21:01 pm »
I have been struggling with a problem..

I am creating a project that needs to record audio, and then combine two recorded sound buffers, so i can save it in a file.

I was reading this topic: http://en.sfml-dev.org/forums/index.php?topic=6970.0

And in the end the user provides a code... The code works perfectly on random .wav(using loadFromFile) files that i found. But when i use the buffer i recorded it doesnt work. It combines the two, but everything is just sped up.

So now i think there is a problem with the bitrate or sample rate of the files. But both the downloaded files and files recorded using SFML have the same Bitrate and Sample rate.

Can someone explain this? Or atleast any ideas what could be the problem here?
Thanks!

Pages: [1]