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

Pages: [1]
1
Audio / Re: Attaching SoundBuffers
« on: February 17, 2017, 07:35:03 pm »
How to work with arrays is basic C++ knowledge and not really SFML specific, so you might want to read up on that topic.

I suggest to use a std::vector, for the rest ypu can also Google it (so I don't have to). And then pass vec.data() to loadFromSamples to the new buffer.

If this operation always occurs at load time, you might just want to merge them in an audio editing software beforehand.

Yes, i know how to work with arrays in c++, that i was trying to say is that is not giving me an array.

btw, Thanks for the suggest .

EDIT: it finally works, im going to try to concatenate now, thanks to both of you

2
Audio / Re: Attaching SoundBuffers
« on: February 17, 2017, 06:59:32 pm »
Quote
So, just need to create a function to concatenate their arrays of audio? (getSamples)
Yes.

Sample rate and channel count obviously need to be the same.

I was trying to work with it but i dont know if im doing it right.
First, i rlly dont know how join to the array, for example:

Quote
>>I have this Buffer:
sf::SoundBuffer buffer1;
sf::SoundBuffer buffer2;

now i want to take the array from the first one. So i should use buffer1.getSamples(); the first thing that i think is that if this is an array i could get the samples of the array like: buffer1.getSamples()[number], i know it is wrong but i dont know how get the data of the array. if i print buffer1.getSamples() just get a number like "0x6668478" and the second buffer give me "0x66ed2f0". I rlly dont know how to concatenate those arrays because i dont know how work with it, i read the def of the function getSamples() but i really dont get it.

Thanks for all your help again

3
Audio / Re: Delay Between Record and Play
« on: February 17, 2017, 03:21:19 pm »
What if you avoid copying the buffer and assign the recorder's buffer directly?

I edited this reply cause now i understand what you were trying to tell me jaja, im going to try and tell you if works!.

Thanks for help.

4
Audio / Re: Attaching SoundBuffers
« on: February 17, 2017, 07:06:21 am »
You can easily concatenate their data (audio samples) and create a new buffer from that.

So, just need to create a function to concatenate their arrays of audio? (getSamples)
or, need i to attach their getSamples, getSamplesCount, getSamplesRate and getChannelCount?

thanks for ur fast reply :)

5
Audio / Attaching SoundBuffers
« on: February 17, 2017, 06:33:15 am »
Hi all,
Well, like the title says,is there any way to attach 2 soundbuffer? like:

Quote
sf::SoundBuffer buffer1;
sf::SoundBuffer buffer2;
sf::SoundBuffer buffer3;
----then i record 2 times for buffer1 and buffer2 and now i want to attach them-----
buffer3 = buffer1 + buffer2;

or other way, is there any way to attach 2 sounds?

Thanks all.

6
Audio / Delay Between Record and Play
« on: February 17, 2017, 01:45:53 am »
Hi all!,
I was writing a little about it in General Section, but i think the main theme of the topic is not the same.

Well, i'm working in a Software for a Loop Pedal. I'm starting with the code, so i'm just trying to do one loop works. So, the idea is record the loop and when i stop record then play the sound recorded. i made this code:

Quote
                if(Event.key.code == sf::Keyboard::R){
                    recorder.start();
                    std::cout<<"> Recording Loop"<<std::endl;
                }
                else if(Event.key.code == sf::Keyboard::S){
                    recorder.stop();
                    clock.restart();
                    std::cout<<"> Playing Loop"<<std::endl;
                    buffer = recorder.getBuffer();
                    sound.setBuffer(buffer);
                    std::cout<<"> Delay Between Record and Play: "<<clock.getElapsedTime().asMicroseconds()<<std::endl;
                    sound.play();
                }

But i need those both actions start at the same time, i mean RECORD.STOP and SOUND.PLAY start together, because later i need to record another sound while im listening the first one and it doesnt have to exist delay. I print the delay between Record.stop and sound.play as MicroSeconds and i got this:



So i have 1570 microseconds between record.stop  and sound play. What can i do to get 0 second of Delay (or close)?.

I think if i put sound.play straight after record.stop it would works, but it couldnt be possible cause there are buffer = recorder.getbuffer() and sound.setbuffer() functions :/. Is there any way to avoid it?


Thanks to all!.

7
General / Re: Using Threads with Sound Functions
« on: February 17, 2017, 12:03:35 am »
I haven't used SFML's audio recording as yet so I have no experience of how it responds.

However, there are two things that could be of note:
  • When you stop recording, are you copying the buffer? This could cause a delay.
  • It's likely that there will be some audio buffer on your soundcard; this playback to be "laggy".

If it's the laggy playback, try making sure nothing else is running - including the IDE - and in release mode. Also, check your soundcard settings and look for a playback buffer and try reducing it. Might also need a restart of your system too.

If it's your recording buffer being copied, try recording directly into the sound buffer instead of copying it. Is that how recording works?

Well, this is the first part of the code:
 
Quote
    sf::SoundBufferRecorder recorder;
    sf::SoundBuffer buffer;
    sf::SoundBuffer buffer2;
    sf::Sound sound;
    sf::Sound sound2;
    sound.setLoop(true);
    sound2.setLoop(true);
    float duration_loop;
    float duration_loop2;

So i dont copying the buffer cause i made a buffer for each audio, so it both exist always.
About SoundCard, im using a professional one, because i need this software to play music in high quality.

I dont really know if im answering your question right. My english is not so good. :(

I mean the real problem is that i cant stop a record of a sound and play it at the same time, there is a delay between stop record and play :(

Also, i noticed that im in the wrong forum, i was right first when i was asking about thread and sound (i think), but now i have problem just with SFML's Audio, have i to post there?

thanks for reply.

8
General / Re: Using Threads with Sound Functions
« on: February 16, 2017, 11:09:38 pm »
Hi again, i know its hard to explain my problem so i did some images. This is the problem jaj :



This is the code that im using:

Quote

sound.setLoop(true);
sound2.setLoop(true);

----------blah----------

                if(Event.key.code == sf::Keyboard::R){
                    recorder.start();
                    std::cout<<"> Recording First Loop"<<std::endl;
                }
                else if(Event.key.code == sf::Keyboard::S){
                    recorder.stop();
                    buffer = recorder.getBuffer();
                    sound.setBuffer(buffer);
                    duration_loop = buffer.getDuration().asMilliseconds();
                    sound.play();
                    std::cout<<"> Recording Second Loop"<<std::endl;
                    recorder.start();
                    clock.restart();
                    while(clock.getElapsedTime().asMilliseconds()<duration_loop)
                        continue;
                    recorder.stop();
                    buffer2 = recorder.getBuffer();
                    sound2.setBuffer(buffer2);
                    sound2.play();
                    duration_loop2 = buffer2.getDuration().asMilliseconds();
                    std::cout<<"First Loop Time: "<<duration_loop<<std::endl;
                    std::cout<<"Second Loop Time: "<<duration_loop2<<std::endl;
                }

and this is what i got:



i know the time of the sound are right, but how i explained in the first images, when you hear both, there is a delay.

Thanks again for help me :)


9
General / Re: Using Threads with Sound Functions
« on: February 16, 2017, 05:08:06 pm »
Sounds are automatically started in their own thread so you can start it and continue with your program.
So, just your first code block would probably be the way to do it.

Oh ok, i didnt know that, but, each sound starts in their own thread?. Because as a loop pedal, it will have a lot of sound recorded playing at the moment and i need all these sounds start at the same time, so i think each sound need to work in a different thread (not really, im thoght how to do it just with 2 thread).

So, if a have 2 sounds and i need those start at the same time, each sound will start in a different thread? or the SOUND LIBRARY have their own thread?.

The real problem that i have is, when i recorded the first sound, i need that sound playing in the background (as loop) while im recording the second sound, when i finish to record the second sound, both have to play at the same time. Well, the problem is: When i play the first sound and im recording the second one, there is a delay between those, but when i finish to record the second one and they both are playing there is not a delay (but i need to have the tempo on my brain and not listen the first sound).

i hope u can understand me :(

Thanks for your help! :D

PS: If someone dont know how a loop pedal works here there is a video:  https://youtu.be/DV0TJZ7Kp40?t=14s

10
General / Using Threads with Sound Functions
« on: February 16, 2017, 06:46:17 am »
Hi all,
Well, im working in a software to a Loop Pedal, so i need to play sounds (recorded in the moment) at the same time that im recording other sounds. example:

Quote
> blah blah
> sound.play();
> recorder.start();
> blah blah

and i need those function start at the same time. i was thinking use this but it didnt work :

Quote
> blah blah
> sf::Thread thread(sound.play());
> thread.launch();
> recorder.start();
> blah blah

Im new using the SFML library, and i really dont know how use SFML threads and the tutorials just talk about how use it with c++ void function, but nothing about sfml functions (or i didnt realize) so any help will help.
Sorry for any english mistake.

I have Windows 10, and im working with CodeForce.

Thanks!

Pages: [1]
anything