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

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.
Owner
Shared repositories.
null
Comments
  • 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.

  • 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)
    
  • 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.

  • 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?

  • 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

  • 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.

  • 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).

  • 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.

  • 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/

  • 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.

  • 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.

  • IETF test cases - 3 of 64 FAIL (61 of 64 PASS) in flac.TestDecode

    IETF test cases - 3 of 64 FAIL (61 of 64 PASS) in flac.TestDecode

    The IETF flac-test-files repository contains 64 FLAC files, published by @ktmf01, which help exercise corner cases of the FLAC decoder.

    When adding these test cases to the test suite, 3 of 64 FLAC files resulted in decoding failures, namely:

        --- FAIL: TestDecode/parse/testdata/flac-test-files/subset/16_-_partition_order_8_containing_escaped_partitions.flac (0.00s)
        --- FAIL: TestDecode/parse/testdata/flac-test-files/subset/32_-_high_resolution_audio,_partition_order_8_containing_escaped_partitions.flac (0.00s)
        --- FAIL: TestDecode/parse/testdata/flac-test-files/subset/64_-_rice_partitions_with_escape_code_zero.flac (0.00s)
    

    This issue tracks the resolution of the identified decoding issues.

    • [ ] 16_-_partition_order_8_containing_escaped_partitions.flac
    • [ ] 32_-_high_resolution_audio,_partition_order_8_containing_escaped_partitions.flac
    • [ ] 64_-_rice_partitions_with_escape_code_zero.flac

    Further tests will be run to also exercise e.g. metadata decoding and decoding of all audio samples.

  • 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.

  • 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.

  • 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.

  • 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

  • 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

Related tags
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

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

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

Oct 24, 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

Dec 23, 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

Dec 31, 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"

Dec 1, 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

Jan 1, 2023
CLI audio player written in go.
CLI audio player written in go.

A very minimal CLI audio player.

Dec 13, 2022
alto is a program built for audio management.
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

Oct 10, 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

Oct 30, 2021
Audio visualizer in Go
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

Dec 4, 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

Nov 17, 2022
ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams
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.

Dec 31, 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

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.

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.

Dec 28, 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

Jun 14, 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

Dec 22, 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

Apr 14, 2022
CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.
CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.

depsdev CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security sig

May 11, 2023
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

Nov 8, 2022