Comments (6)
@djevo1 the gem doesn't support reading cue/marker points from wave files. I don't think there's a fundamental reason why the gem couldn't support this in the future, but I'm not very familiar with this type of chunk and haven't personally had a reason to use it myself before.
Have you used wave file cue points before? If the gem supported reading cue points from wave files, is there a particular use case you would have in mind?
from wavefile.
@jstrait I was looking for the same as I want to split a portion of the wave file. BTW how do I split wave file? I didn't find any example for splitting files.
from wavefile.
@zoras can you say more about how you are wanting to split the file? Are you wanting to split it based on cue/marker points? Or some different way? What is the bigger thing you are trying to accomplish by splitting the file? (Just asking because it might help me give a better answer).
As an example, if you wanted to split a file so that every 100,000 samples went to a different file, this is one way you could do it:
require 'wavefile'
include WaveFile
SAMPLE_FRAMES_PER_FILE = 100000
OUTPUT_FORMAT = Format.new(:stereo, :pcm_16, 44100)
file_name = "input_file.wav"
file_index = 1
Reader.new(file_name).each_buffer(SAMPLE_FRAMES_PER_FILE) do |buffer|
Writer.new("output_file_#{file_index}.wav", OUTPUT_FORMAT) do |writer|
writer.write(buffer)
end
file_index += 1
end
from wavefile.
@jstrait I am working with wavefile and wanted to trim the audio file let's say of 10:00 minutes from 3:00 to 7:00 mins. At the moment, I'm using audio-trimmer to accomplish the same.
from wavefile.
@zoras there's not a direct way to do that, but you could do it like this:
- Read sample frames (but throw them away) until you reach the starting trim point
- Next, read sample frames until the ending trim point, and write them to the output file.
For example, something like this:
require 'wavefile'
include WaveFile
STARTING_NUMBER_OF_SECONDS = 3 * 60 # Starting point is 3 minutes into file
ENDING_NUMBER_OF_SECONDS = 7 * 60 # Ending point is 7 minutes into file
Reader.new("file_to_trim.wav") do |reader|
STARTING_SAMPLE_FRAME = reader.format.sample_rate * STARTING_NUMBER_OF_SECONDS
ENDING_SAMPLE_FRAME = reader.format.sample_rate * ENDING_NUMBER_OF_SECONDS
# Read up to the starting trim point
throwaway_buffer = reader.read(STARTING_SAMPLE_FRAME)
Writer.new("trimmed_file.wav", reader.format) do |writer|
buffer = reader.read(ENDING_SAMPLE_FRAME - STARTING_SAMPLE_FRAME)
writer.write(buffer)
end
end
Hope that helps!
from wavefile.
I just added loop information extraction in another project. I've forked this repo and expect to implement the same here :)
from wavefile.
Related Issues (20)
- Possible bug when no block is given to the writer? HOT 2
- No high-level duration info HOT 2
- Example here - https://github.com/jstrait/wavefile/wiki/WaveFile-Tutorial#copying-a-wave-file-to-different-format working correctly? HOT 5
- fyi: ruby-wavefile now packaged for Debian HOT 1
- support reading from a file or stream HOT 5
- Duration does not override equality HOT 2
- UnsupportedFormatError HOT 8
- each_buffer causes ReaderClosedError HOT 3
- Reference for older methods HOT 4
- examples: how create reverse file? HOT 2
- Mix 2 wav files. HOT 2
- Rewind the IO object HOT 4
- Format Chunks With Extra Bytes at the End Sometimes Cause `InvalidFormatError` to be Raised HOT 1
- `Reader` instances can be created for WAVE_FORMAT_EXTENSIBLE files that have an incomplete/missing format chunk extension HOT 1
- Bufer from bytes & mulaw HOT 2
- WaveFile::Reader doesn't work with pipe IO HOT 2
- Sample Data Can't Be Read From a WAVE_FORMAT_EXTENSIBLE File With an Oversized Format Chunk Extension HOT 1
- How i can play file HOT 1
- Misleading error message if "fmt " chunk extension is too large to fit into chunk HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wavefile.