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

Pages: [1]
1
Graphics / Add vertices to a vector
« on: April 24, 2018, 02:30:13 am »
I'm trying to draw about a hundred lines on the screen. So far I'm testing my code with adding only two vertices to a vector but the code won't compile because of

error: expected primary-expression before ']' token vertices.push_back(line[]);

I'm not really experienced in C++ and any help would be greatly appreciated.

Here's my code so far.

    std::vector <sf::Vertex> vertices;

    sf::Vertex line[] =
    {
        sf::Vertex(sf::Vector2f(1, 0), sf::Color::Red),
        sf::Vertex(sf::Vector2f(1, 150), sf::Color::Green),
    };

    sf::Vertex line2[] =
    {
        sf::Vertex(sf::Vector2f(3, 0), sf::Color::Red),
        sf::Vertex(sf::Vector2f(3, 150), sf::Color::Green)
    };

    vertices.push_back(line[]);
    vertices.push_back(line2[]);

2
Audio / Re: How to get the current audio sample?
« on: March 31, 2018, 02:39:41 pm »
Thank you! When I think about it your answer makes a lot of sense. I'm new to SFML and C++ programming as a whole so I really appreciate you taking the time to explain what I was doing wrong. One last thing I want to ask is what is a good source to read more about signal processing and where did you start learning from?

3
Audio / How to get the current audio sample?
« on: March 31, 2018, 02:10:28 pm »
I'm trying to apply a Fourier Transform on the current audio sample. This is how I'm accessing all samples and storing them in a variable.
const auto samples = buffer.getSamples();
To get the current playing position I'm using
sf::Sound::getPlayingOffset() const
because this is the closest thing I found to what I'm trying to achieve. However, I don't think it will work in my case because the only usage of this method I found is to return the seconds of playback that have elapsed.
  while (sound.getStatus() == sf::Sound::Playing){
    // Display the playing position
    std::cout << "\rPlaying... " << sound.getPlayingOffset().asSeconds() << " sec";
    std::cout << std::flush;
  }

My question is is there a way I can access only the current sample that is played and apply Fourier Transform to it. If yes which methods should I be looking at?

4
Thank you, it's working now!

5
When I try to find the samples of other files I get only zeros. Here's my code. This https://freesound.org/people/reaktorplayer/sounds/99674/ is the reaktor.wav I'm using.
  sf::SoundBuffer buffer;

  if(!buffer.loadFromFile("reaktor.wav")){
    std::cout << "didn't load properly";
    return -1;
  }

  const sf::Int16* samples = buffer.getSamples();

  for (int i = 0; i < 44; i++){
    std::cout << samples[i] << std::endl;
  }
 

Should I be doing something differently?

6
Audio / What values should I expect to be returned from buffer.getSample()?
« on: February 18, 2018, 08:07:53 pm »
I have an array
const sf::Int16* samples = buffer.getSamples();
and I access it like
samples[i];
and I get values ranging from -4 to 4.

Is this what the output should be because samples are returned as 16 bits signed integers and I was looking for values ranging from −32,768:32,767?

Pages: [1]
anything