filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.15k stars 451 forks source link

Split Audio #435

Closed engmohamedsalah closed 3 years ago

engmohamedsalah commented 3 years ago

How I can use this library to split audio into chunks for example, I have an audio file with a size of 100 seconds I need to cut that into small files from as following a file contains the audio from second 0 to second 4 a file contains the audio from second 23 to second 40 a file contains the audio from second 80 to second 90

filoe commented 3 years ago
  1. Open the audio file using the CodecFactory
  2. Convert e.g. 4 seconds to the number of bytes you have to read by calling the extension method GetRawElements using the created IWaveSource returned in step one
  3. Read the number of bytes using the Read method of the IWaveSource object
  4. Save the read data to a file. For example, you could use the WaveWriter and repeat step 3 and 4.