Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using SoundBuffer to split audio files?  (Read 3135 times)

0 Members and 1 Guest are viewing this topic.

s.baus

  • Newbie
  • *
  • Posts: 45
    • View Profile
Using SoundBuffer to split audio files?
« on: February 24, 2018, 01:17:29 pm »
Hello everybody,
I use SFML successfully inside my project for audio playback and like it very much. I use the C# binding and now have the task to split an audio file into little files (one large file about 2 hours into files of some minutes). Since I need a plattform independent framework (my project is build with mono/gtk-sharp,etc.) and didn't find any valuable framework I thought of using SFML for this task. So I took a look inside and found the SoundBuffer class, which already has the SaveToFile method and the internal handling for different file formats (the audio file can be ogg/wave/flac/mp3 (I know, it is not supported by SFML, wrote a wrapper myself)). The splitting will be done from time x to time y. How can I find out, where the samples of SoundBuffer belong to, meaning, which time they stand for?

Do you think this task can be achieved with this approach?
Thanks for respones.
Sven
AudioCuesheetEditor, your #1 CuesheetEditor.

http://sourceforge.net/projects/audiocuesheet

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Using SoundBuffer to split audio files?
« Reply #1 on: February 24, 2018, 02:58:52 pm »
The sound buffer has a function to get the samples rate (samples per second) and the channel count (e.g. stereo = 2) and the samples themselves which are interleaved for each channel (e.g. LRLRLRLRLR...).

All you need now is math to convert from time to number of samples. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

s.baus

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Using SoundBuffer to split audio files?
« Reply #2 on: February 24, 2018, 03:58:32 pm »
Thanks for your response, this helps me really a lot, since I didn't know, how the samples are structured.

Does SoundBuffer recognize in which file format it should save on the file extension, or is there something I have to keep in mind? Since I think wave, ogg, flac are not all the same?! :)
AudioCuesheetEditor, your #1 CuesheetEditor.

http://sourceforge.net/projects/audiocuesheet

 

anything