Package flac provides access to FLAC (Free Lossless Audio Codec) streams.

Related tags

Audio & Music flac
Overview

flac

Build Status Coverage Status GoDoc

This package provides access to FLAC (Free Lossless Audio Codec) streams.

Documentation

Documentation provided by GoDoc.

  • flac: provides access to FLAC (Free Lossless Audio Codec) streams.
    • frame: implements access to FLAC audio frames.
    • meta: implements access to FLAC metadata blocks.

Changes

  • Version 1.0.7 (2021-01-28)

  • Version 1.0.6 (2019-12-20)

    • Add experimental Encoder API to encode audio samples and metadata blocks (see #32).
    • Use go.mod.
    • Skip ID3v2 data prepended to flac files when parsing (see 36cc17e).
    • Add 16kHz test case. Thanks to Chewxy.
    • Fix lint issues (see #25).
  • Version 1.0.5 (2016-05-06)

    • Simplify import paths. Drop use of gopkg.in, and rely on vendoring instead (see azul3d/engine#1).
    • Add FLAC decoding benchmark (see d675e0a)
  • Version 1.0.4 (2016-02-11)

    • Add API examples to documentation (see #11).
    • Extend test cases (see aadf80a).
  • Version 1.0.3 (2016-02-02)

    • Implement decoding of FLAC files with wasted bits-per-sample (see #12).
    • Stress test the library using go-fuzz (see #10). Thanks to Patrick Mézard.
  • Version 1.0.2 (2015-06-05)

  • Version 1.0.1 (2015-02-25)

    • Fix two subframe decoding bugs (see #7). Thanks to Jonathan MacMillan.
    • Add frame decoding test cases.
  • Version 1.0.0 (2014-09-30)

    • Initial release.
    • Implement decoding of FLAC files.
Issues
  • 24/96 flac content

    24/96 flac content

    Are 24 bps 96khz flac files supported in general? Has anyone played back such content via mewkiz/flac? With the help of mewkiz/flac and gordonklaus/portaudio I am able to play back standard 16/44.1 flac files (some perfectly / some almost perfectly, see #29 ). However, I'm not yet able to play back 24/96 files in the same way. The problem is most likely in my code. But it could also be an issue in either mewkiz/flac or gordonklaus/portaudio. This is why I would like to ask if anybody has managed to play back 24/96 flac content from their Go app. (I can play back 24/96 flac files via VLC to my USB DAC in bitperfect fashion. Just not via my Go app, yet.) Thank you.

    opened by mehrvarz 21
  • Vendor our dependencies with `vgo`

    Vendor our dependencies with `vgo`

    Result from vgo test all:

    ok  	azul3d.org/engine/audio	(cached)
    --- FAIL: TestDecodeFloat32 (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeFloat64 (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeUInt8 (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeInt16 (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeInt24 (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeInt32 (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeALaw (0.00s)
    	decode_test.go:34: audio: unknown format
    --- FAIL: TestDecodeMuLaw (0.00s)
    	decode_test.go:34: audio: unknown format
    FAIL
    FAIL	azul3d.org/engine/audio/wav	0.371s
    ok  	github.com/djimenez/iconv-go	(cached)
    ok  	github.com/icza/bitio	(cached)
    ok  	github.com/icza/mighty	(cached)
    ok  	github.com/mewkiz/flac	(cached)
    ?   	github.com/mewkiz/flac/cmd/flac2wav	[no test files]
    ?   	github.com/mewkiz/flac/cmd/go-metaflac	[no test files]
    ok  	github.com/mewkiz/flac/frame	(cached)
    ok  	github.com/mewkiz/flac/internal/bits	(cached)
    ?   	github.com/mewkiz/flac/internal/hashutil	[no test files]
    ok  	github.com/mewkiz/flac/internal/hashutil/crc16	(cached)
    ok  	github.com/mewkiz/flac/internal/hashutil/crc8	(cached)
    ok  	github.com/mewkiz/flac/meta	(cached)
    ok  	github.com/mewkiz/pkg/errutil	(cached)
    ?   	github.com/mewkiz/pkg/osutil	[no test files]
    ?   	github.com/mewkiz/pkg/pathutil	[no test files]
    ?   	github.com/mewkiz/pkg/term	[no test files]
    ok  	github.com/mikkyang/id3-go/encodedbytes	(cached)
    
    opened by karlek 11
  • FLAC Encoder, metadata support

    FLAC Encoder, metadata support

    I want to update some metadata blocks (Vorbis comments) and re-encode the Stream. Is it planned? If not, any hints on how to do it (within the current API design)?

    I love how close this library is to the FLAC specifications, I enjoyed using it, thank you.

    opened by varyoo 11
  • Vendor our dependencies

    Vendor our dependencies

    Since we depend on a few libraries, and a few projects depends on us, it would be high time to start vendoring our dependencies.

    The only problem is in deciding which dependancy manager to use. I argue that we first use dep, until vgo leaves the prototype stage. However, bleeding edge is also fun in itself.

    What's your take on this @mewmew?

    opened by karlek 10
  • High bitrate, small devices

    High bitrate, small devices

    Hi. Playing hires audio on a RPi can easily drive 50-70% cpu load. You live by the "Output underflowed" message. It only takes another high priority task (sshd) to move a little finger and... bang. But CPU load could be brought down easily. All it would take is for the decoder to interleave the audio channels: LLLLRRRRLLLLRRRRLLLLRRRR... Audio subsystems prefer it this way. Other decoders do this too. Can we have frame.Samples[i] without subframes? Would it be possible to pick the outgoing format when opening a file? Thank you for considering

    opened by mehrvarz 8
  • subframe: turn panics into errors

    subframe: turn panics into errors

    Hello,

    I have run go-fuzz on the flac package and it eventually triggered panics by supplying invalid user inputs. I believe panics should be reserved to internal invariant violations or irrecoverable errors, not invalid user inputs, so this change turns them into errors.

    opened by pmezard 8
  • Seek

    Seek

    WIP!!!

    I got something working with seek table and fixed block sized flac. I'm making a PR now just to see if you think I'm on the right track before going too far.

    If the Flac file doesn't have a seek table in its metadata then this builds one. I still need to make it work for FixedBlockSize=false Flac files (gotta find a file like this first).

    opened by cswank 6
  • Seek support

    Seek support

    From flac.go:

    // TODO: Implement a Seek method.
    

    Creating this issue to facilitate an open discussion on how we may implement audio seek support in the future. What do we need to keep in mind?

    • Performance?
    • How should the API look like?
    • Should we require a seek table to be present in the metadata?
    • Should we make use of the sync codes to seek when no seek table is present?
    • Will we require the underlying stream to implement io.Seeker?

    Some notes from the x/audio proposal:

    @rakyll wrote at https://github.com/golang/go/issues/13432#issuecomment-184853011

    Seeking is often expensive, we may adopt an io.ReadSeeker-like interface to make Seek a standalone operation to put some more emphasis on its cost.

    help wanted 
    opened by mewmew 6
  • Sample with Rice parameter escape codes

    Sample with Rice parameter escape codes

    invalid-residual.flac.zip

    This triggered:

    frame.Subframe.decodeRicePart: The flac library test cases do not yet include any audio files with Rice parameter escape codes. If possible please consider contributing this audio sample to improve the reliability of the test cases.

    The sample is a corruption of https://freesound.org/people/krestivo/sounds/27951/

    opened by 0xbzho 5
  • Slight audio playback issues with some flac files depending on header block size?

    Slight audio playback issues with some flac files depending on header block size?

    Hi. Some of my flac files don't play back perfectly. The issue appears to depend on the block size in the header. blockSize=12 results in frame.BlockSize=4096 which plays back perfectly. blockSize=5 results in frame.BlockSize=4608 which comes out slightly scrambled. Any idea what could be causing this? Thank you.

    opened by mehrvarz 5
  • Fix two bugs with subframe decoding

    Fix two bugs with subframe decoding

    Fix two bugs with subframe decoding in the FLAC library:

    • the linear predictive coding has an overflow error -- with FIR-encoded frames, this often causes the output signal to be noise rather than what it should be. Type-converting to int64 to do the summation, then back to int32 after shifting fixed this for the files that I tested against.
    • the check if the Rice parameter was the escape code did not handle the 5-bit escape code -- it checked for 0x1f and a 4-bit-long code instead of a 5-bit-long one

    I don't have any FLAC files that test the latter issue; I have a number of FLAC files that caused the former, all of which were very noisy before and are sonically correct now.

    opened by perotinus 5
  • FLAC decoder testbench

    FLAC decoder testbench

    I just found your FLAC decoding library, and tested it through flac2wav with this FLAC decoder testbench. I got quite a lot of messages like these

    The flac library test cases do not yet include any audio files with xxx. If possible please consider contributing this audio sample to improve the reliability of the test cases.

    For this I recommend the FLAC decoder testbench I just linked.

    Besides the messages, flac2wav fails to decode the following files:

    • 16 - partition order 8 containing escaped partitions
    • 22 - 12 bit per sample
    • 32 - high resolution audio, partition order 8 containing escaped partitions
    • 37 - 20 bit per sample

    Also, decoding of 23 - 8 bit per sample seems to be non-lossless.

    I hope this information helps you to even further improve this library.

    opened by ktmf01 5
  • Reason for using sized integer types in `StreamInfo` and `frame.Header`

    Reason for using sized integer types in `StreamInfo` and `frame.Header`

    Hi there! I've been playing around with a small audio streaming project in go using this library. Thanks for the great work :)

    I was wondering why you chose to use unsigned and sized integer types for all of the values in StreamInfo? Did you find that this provided a measurable performance benefit? My expectation would be that using types other than int would provide little to no performance benefits on a 32bit or 64bit architecture. The go documentation recommends generally using int unless there is a specific reason not to.

    It makes working with the library quite tedious because of the high number of conversions between integer types required when performing logic or calculations with the StreamInfo and frame.Header fields. One of the first things I have done is write my own equivalent type with ints. I have a strong aversion to boilerplate unless it serves a purpose so it'd be good to understand what drove this decision.

    I'd be happy to submit a pull request if you think that this would be a good change. However it would be a breaking change so perhaps best bundled with other breaking changes for a future major release.

    opened by BenWhetton 2
  • Re-Implement the flac.Encode(f, stream) function

    Re-Implement the flac.Encode(f, stream) function

    Hi, It's great that you're attempting to implement a new encoder API, but after some testing with it I've not got a path forward with existing files, which are using a non-implemented prediction codec:

    ERROR: github.com/mewkiz/flac.encodeSubframe (encode_subframe.go:38): error: support for prediction method 3 not yet implemented

    Previously, I could use flac.Encode(...) to achieve simple metadata editing, which works on those files but that was removed in favour of the new Encoder API.

    Looking for a suggestion as to how best to proceed - should I attempt to re-implement the flac.Encode function within my own code, or is there something I'm missing when trying to change just the metadata, and not the samples.

    opened by spbkaizo 4
  • Audio Compression

    Audio Compression

    Hi, I'm interested to know if this package compresses audio when encoding it to flac. I have tried out the wav2flac program in the cmd folder however when given a 5 second stereo wav file sampled at 48kHz, the flac file produced is larger by 240kb.

    Since wav is uncompressed and flac is supposed to be encoded using lossless compression, I was expecting a smaller file size. Am I missing something? Thanks, -Trek

    opened by trekhopton 1
  • Any plans for replaygain scanning support?

    Any plans for replaygain scanning support?

    Hi. I found this project via search and it looks amazing. I haven't yet had a chance to look at it in detail, so I'm sorry if missed obvious answers to my questions.

    Do you think it's worth implementing a feature that repeats metaflac --add-replay-gain behavior? Does this feature even belong here?

    Or should I instead use this project to decode flac to pcm and use something else to determine loudness? Do you happen to know go libraries that would do that?

    Thanks

    opened by edio 2
  • Implement LPC encoding of audio samples

    Implement LPC encoding of audio samples

    Notes from @wsc1 at https://github.com/mewkiz/flac/pull/32#issuecomment-420835961

    For the LPC stuff, just wanted to note this mail

    this chapter

    and zc lpc

    So one possible way to approach flac LPC (the fixed LPC shouldn't require this BTW) would be to extend zc/lpc to use line spectral pairs, expose the parcor coefficients, and work with some of the quantisation methods in the chapter.

    If that is of interest to you, I'm happy to collaborate.

    opened by mewmew 0
Owner
Shared repositories.
null
Local-audio - Web walking audio tour platform proof-of-concept

Goal: Proof of concept for a Web Audio walk platform Data retention dynamdo db "time to live" expires in 1 day from creation of record set in add.go s

Kai Hendry 3 Jan 9, 2022
Simple cli utility to show bitrate/samples of flac files in a directory

flac-specs Simple cli utility to show bitrate/samples of flac files in a directory I needed a quick little utility that would look at the flac files i

Kevin Foss 0 Dec 14, 2021
GAAD (Go Advanced Audio Decoder)

GAAD (Go Advanced Audio Decoder) Package currently provides AAC parsing capabilities. This package performs a full parse of AAC-LC and HE-AACv1 bitstr

null 98 May 7, 2022
Go tools for audio processing & creation ?

GoAudio ? GoAudio is an audio processing library, currently supporting WAVE files, although some tools such as the synth and breakpoints are encoding

Dylan Meeus 221 May 7, 2022
Mini audio library

malgo Go bindings for miniaudio library. Requires cgo but does not require linking to anything on the Windows/macOS and it links only -ldl on Linux/BS

Milan Nikolic 171 May 7, 2022
Sequence-based Go-native audio mixer for music apps

Mix https://github.com/go-mix/mix Sequence-based Go-native audio mixer for music apps See demo/demo.go: package main import ( "fmt" "os" "time"

null 154 Apr 11, 2022
Go bindings for the PortAudio audio I/O library

portaudio This package provides an interface to the PortAudio audio I/O library. See the package documentation for details. To build this package you

Gordon Klaus 503 May 6, 2022
CLI audio player written in go.

A very minimal CLI audio player.

Dave Hulihan 42 Apr 8, 2022
alto is a program built for audio management.

alto, a music organizer alto is a program built for audio management. It's purpose is to provide the user the means to create a path construct to move

null 20 Apr 5, 2022
Terrible Audio Downloader

Terrible Audio Downloader This is just a small go project I did for myself, to manage my audio library to get away from spotify. All it does is downlo

null 0 Oct 30, 2021
Audio visualizer in Go

demo_audio_visualizer Simple audio visualizer in Go Used libraries: raylib-go go-mp3 oto go-dsp To disable the additional console window on Windows OS

Miretz 1 Mar 8, 2022
Go package capable of generating waveform images from audio streams. MIT Licensed.

waveform Go package capable of generating waveform images from audio streams. MIT Licensed. This library supports any audio streams which the azul3d/e

Matt Layher 349 Apr 18, 2022
ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams

rtsp-simple-server is a simple, ready-to-use and zero-dependency RTSP / RTMP server and proxy, a software that allows users to publish, read and proxy live video and audio streams. RTSP is a specification that describes how to perform these operations with the help of a server, that is contacted by both publishers and readers and relays the publisher's streams to the readers.

Alessandro Ros 3k May 9, 2022
Local-audio - Web walking audio tour platform proof-of-concept

Goal: Proof of concept for a Web Audio walk platform Data retention dynamdo db "time to live" expires in 1 day from creation of record set in add.go s

Kai Hendry 3 Jan 9, 2022
Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package.

Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package. The library allows you to call Go service methods from PHP with a minimal footprint, structures and []byte support.

Spiral Scout 1.1k May 18, 2022
Port of LZ4 lossless compression algorithm to Go

go-lz4 go-lz4 is port of LZ4 lossless compression algorithm to Go. The original C code is located at: https://github.com/Cyan4973/lz4 Status Usage go

Бранимир Караџић 207 Apr 9, 2022
Kanzi is a modern, modular, expendable and efficient lossless data compressor implemented in Go.

kanzi Kanzi is a modern, modular, expendable and efficient lossless data compressor implemented in Go. modern: state-of-the-art algorithms are impleme

null 409 May 10, 2022
Slipstream is a method for lossless compression of power system data.

Slipstream Slipstream is a method for lossless compression of power system data. Design principles The protocol is designed for streaming raw measurem

Synaptec Ltd 4 Apr 14, 2022
H265/HEVC HM Video Codec in Go

GoHM H.265/HEVC HM Video Codec in Go Release Note: +v1.0.b03092013 -fix multiple bugs in decoder +v1.0.b03032013 -Initial release candidate for GoHM 1

Rain Liu 58 Dec 22, 2021
ID3, MP4 and OGG/FLAC metadata parsing in Go

MP3/MP4/OGG/FLAC metadata parsing library This package provides MP3 (ID3v1,2.{2,3,4}) and MP4 (ACC, M4A, ALAC), OGG and FLAC metadata detection, parsi

David Howden 377 May 9, 2022
idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]

go-codec This repository contains the go-codec library, the codecgen tool and benchmarks for comparing against other libraries. This is a High Perform

Ugorji Nwoke 1.7k May 13, 2022
A codec for Go structs with support for chainable encoding/decoding hooks.

structool A codec for Go structs with support for chainable encoding/decoding hooks. Features Provide a uniform codec by combining mapstructure and st

Luo Peng 11 Jan 15, 2022
Image compression codec for 16 bit medical images

MIC - Medical Image Codec This library introduces a lossless medical image compression codec MIC for 16 bit images which provides compression ratio si

Kuldeep S 0 Dec 26, 2021
Simple cli utility to show bitrate/samples of flac files in a directory

flac-specs Simple cli utility to show bitrate/samples of flac files in a directory I needed a quick little utility that would look at the flac files i

Kevin Foss 0 Dec 14, 2021
redisqueue provides a producer and consumer of a queue that uses Redis streams

redisqueue redisqueue provides a producer and consumer of a queue that uses Redis streams. Features A Producer struct to make enqueuing messages easy.

Robin Joseph 80 Mar 24, 2022
A Golang lock-free thread-safe HashMap optimized for fastest read access.

hashmap Overview A Golang lock-free thread-safe HashMap optimized for fastest read access. Usage Set a value for a key in the map: m := &HashMap{} m.S

Cornel 1.1k May 7, 2022
Store files in Telegram messages for free and access them from a modern Web UI

Telegram Storage Store files in Telegram messages for free and access them in a nice web UI. Telegram allows to store files (of max 2GB each) for a un

Jack 18 Apr 21, 2022
Rotating cache for small data with lock-free access.

Rotating cache Byte cache implementation with lock-free access. Designed to work with small data under high pressure. Lock-free access (both read and

Voykov Konstantin 0 Dec 5, 2021
Fonts is a package that provides helpers to access font details and easily retrive font bytes with ZERO dependencies

Fonts Fonts is a package that provides helpers to access font details and easily retrieve font bytes. This package has ZERO 3rd-party dependencies. Fo

Go Swiss 10 Mar 3, 2022