Skip to content
/ vave Public

🌊 A crazy simple library for reading/writing WAV files in V. Zero dependencies, 100% cross-platform.

License

Notifications You must be signed in to change notification settings

thecodrr/vave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌊 Vave

A crazy simple library for reading/writing WAV files written in V!

Installation:

Install using vpkg

vpkg get https://github.com/thecodrr/vave

Install using V's builtin vpm (you will need to import the module with: import thecodrr.vave with this method of installation):

v install thecodrr.vave

Install using git:

cd path/to/your/project
git clone https://github.com/thecodrr/vave

Then in the wherever you want to use it:

import thecodrr.vave //OR simply vave depending on how you installed

And that's it!

Usage

This library is in use in the vspeech (V Bindings for DeepSpeech) utility that uses Mozilla's DeepSpeech for Speech-to-Text. Do check that out as well.

vave.open(path,mode)

Open a new WAV file in the specified mode. All mode supported by C.fopen are supported (e.g. r, rb etc.)

mut wav := vave.open("/path/to/vave/file", "r") //open for reading

NOTES: The data is read into a byteptr and needs to be manually freed each and everytime or it will cause a huge memory leak. This library has been tested with valgrind and after freeing there is no other memory leak (if you find any, do report). I haven't implemented writing samples yet due to lack of time but its in my future plans.

WavFile struct

WavFile struct is used for reading/writing samples and other metadata. It is returned by vave.open.

Read:

WavFile.read_raw()

Read all the samples from the file in their raw form.

WaveFile.read_samples(count)

Read a specific amount of samples from the file.

WaveFile.read_sample()

Read only one sample from the file.

Write:

TODO

WaveFile.close()

Close the file and free all associated resources.

Metadata Methods:

WaveFile.total_samples()

Get total number of audio samples in the file.

WaveFile.duration()

Get total duration of the audio file.

WaveFile.data_len()

Get the total length of sample bytes in the file.

WaveFile.bytes_per_sample()

Get total bytes per each sample.

WaveFile.sample_rate()

Get the sample rate (samples per second).

WaveFile.sample_size()

Get the size of one sample()

WaveFile.format()

Get the format of the WAV audio. Either PCM, IEEE, ALAW,MULAW or EXTENSIBLE.

WaveFile.num_channels()

Get the total number of channels in the audio stream.

WaveFile.valid_bits_per_sample()

Get the bits per each sample.

Supported Formats:

Currently only the following formats are supported:

  1. PCM

  2. IEEE

  3. ALAW

  4. MULAW

  5. EXTENSIBLE

Find this library useful? ❀️

Support it by joining stargazers for this repository. ⭐or buy me a cup of coffee And follow me for my next creations! 🀩

License

MIT License

Copyright (c) 2019 Abdullah Atta

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

🌊 A crazy simple library for reading/writing WAV files in V. Zero dependencies, 100% cross-platform.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages