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

Pages: [1]
1
Audio / Re: How to split channels
« on: April 25, 2018, 07:21:40 pm »
Quote
I have no idea where you heard that
Actually, this is the bad source, though probably I misread it ;)
https://stackoverflow.com/questions/48804523/is-it-possible-to-split-left-and-right-channel-from-audio-sample-in-sfml

Quote
Hope that helps.
It really helps a lot!! Thank you!! I've been stuck for hours thinking about how to split those 16 bits.  :o

2
Audio / How to split channels
« on: April 25, 2018, 06:49:39 pm »
Hi!

I am loading a WAV file with sf::InputSoundFile in C++ and I want to extract the samples for each channel separately. As far as I know the method sf::InputSoundFile::read(Int16 *samples, Uint64 maxCount) writes an array of interleaved samples to samples. Each sample is then made up by 16 bits, the first 8 belonging to a channel, and the remaining 8 belonging to the other. My silly question is: should I consider each 8-bits part as an Int8 or as a Uint8? I am very much confused.

A code snippet that performs the conversion from interleaved to separate channels would be also appreciated!  ;D

What follows is my attempt to do this conversion.

sf::Int16 samples[1024];
sf::Int16 mono[1024];
file.read(samplesData, 1024);
if (file.getChannelCount() == 2){
  for(int k = 0; k < 1024; ++k){
    sf::Int16 right = samples[k] & 0x00FF;
    sf::Int16 left = (samples[k] & 0xFF00) >> 8;
    mono[k] = (right+left)/2; // mean of the two channels
  }
}

Pages: [1]
anything