Commit graph

311 commits

Author SHA1 Message Date
DataHoarder 594dc137ca
Update dependencies 2023-03-03 07:56:36 +01:00
DataHoarder 2ac188033a
Remove flac2wav / wav2flac examples on cmd 2022-11-30 08:02:59 +01:00
DataHoarder 28f458bc53
Automatically select best subframe encoding predictor 2022-07-26 17:10:57 +02:00
DataHoarder e1a48c4800
fix: encodeFrameHeaderBlockSize special encoding 2022-07-26 16:14:42 +02:00
DataHoarder 18f6041006
fix wav2flac encoding 2022-07-26 16:14:42 +02:00
DataHoarder 3c16c77da5
Update dependencies 2022-07-26 16:14:42 +02:00
DataHoarder 42f940f815
Update module url 2022-07-26 16:14:37 +02:00
Robin 42d25f4866
cmd/flac2wav: fix encoding of 8-bps WAV; should use uint8, was using signed int (#52)
ref: https://github.com/mewkiz/flac/issues/51#issuecomment-1046183409

Updates #mewkiz/flac#51.
2022-02-20 17:01:16 +01:00
Henry Eklind 59ff7d9caa
fix/flac: Actually print relevant incorrect type (#49)
* fix/flac: Actually print relevant incorrect type

`si` will always be `(*meta.StreamInfo)`, the relevant type is
`block.Header.Type` which implements `Stringer`

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

Co-authored-by: Robin <mewmew@users.noreply.github.com>
2022-01-01 12:11:04 +01:00
Robin Eklind 69bef32f45 readme: update release date of v1.0.7 and add ref to #46 2021-01-28 00:38:31 +01:00
Robin Eklind 48c2491b7c flac: add nil return in searchFromStart to fix build
Also, rename sample to sampleNum for consistency.

Use line80 comments like it is the summer of 1969.
2021-01-28 00:32:43 +01:00
Henry Eklind 11466d8af8
Absolute seek (#46)
* frame: Add frame.SampleNumber()

* flac/seek: Make stream.Seek seek to absolute sample numbers

* seek/test: Update test case for absolute seeking

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac_test.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update frame/frame.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* flac: Improve code styling

* flac: Add ErrNoSeeker documentation comment

* flac: Make searchFromStart return an error instead of panic

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

Co-authored-by: Robin <mewmew@users.noreply.github.com>
2021-01-28 00:23:27 +01:00
Robin Eklind bb157a5067 flac: use io.ReadSeeker as parameter of NewSeek 2021-01-23 18:05:53 +01:00
Henry Eklind b8e364af30
Update README.md 2021-01-23 17:44:19 +01:00
Henry Eklind 068bbda5ab
Update README.md 2021-01-23 17:43:44 +01:00
Craig Swank 052c3e4f58
Implement seek (#44)
* Implement seek

* update tests

* fixed io.SeekCurrent seek

* rename test

* Tweak seekTable reserved slice size

* fixed a seek bug

* brush up comment

* a little cleanup

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* CR changes

* remove unused Err

* try to make comment easier to understand

* comment edit

Co-authored-by: Robin <mewmew@users.noreply.github.com>
2021-01-23 17:38:38 +01:00
Robin Eklind 0b3d4b0db5 update dependencies using go get -u ./...
In particular, bitio.Writer -> *bitio.Writer in github.com/icza/bitio

Updates #39.
2019-12-20 21:27:52 +01:00
Robin Eklind 4f9da84df5 travis: use CI scripts from mewmew/ci instead of Gist 2019-12-20 21:16:10 +01:00
Robin Eklind 41d812b2e4 readme: add release notes for version 1.0.6 2019-12-20 21:09:38 +01:00
Robin Eklind ce80303686 update .gitignore 2019-12-20 20:39:38 +01:00
Robin Eklind f296b7aa79 update go.mod 2019-02-23 00:13:44 +09:00
mewmew c28568d4b1 flac: add notice about Encoder API being experimental until 1.1.x 2018-08-20 14:59:42 +09:00
mewmew a17e4ae49e flac: add constant encoding of samples 2018-08-20 04:24:38 +09:00
Robin Eklind 3e3f4b5fcf
flac: add Encoder API to encode audio samples and metadata blocks (#32)
* flac: encode frame header

* flac: calculate CRC-8 when encoding frame headers

* flac: fix encoding of frame header

* flac: add preliminary subframe encoder

* flac: fix UTF-8 encoding of frame number

* frame: add sanity check for sample count in decodeLPC

Updates #31.

* flac: update flac encoding API, depricate flac.Encode

Encode has been removed in favour of using NewEncoder.
The Encode function was temporarily added to support
re-encoding FLAC streams to update the metadata, but
it had no support for encoding audio samples.

The added flac.Encoder has support for encoding both
metadata and audio samples. It also does not require
that you first decode a FLAC file to later re-encode
it by calling Encode (as was the previous behaviour).

* flac: add MD5 running hash of unencoded audio samples to StreamInfo

* flac: remove unused encodePadding

Reported by golangci

* flac: fix golangci lint issues

	frame/utf8.go:57:6: `decodeUTF8Int` is unused (deadcode)
	func decodeUTF8Int(r io.Reader) (n uint64, err error) {
		  ^
	internal/utf8/encode.go:32:16: unnecessary conversion (unconvert)
			bits = uint64(t2 | (x>>6)&mask2)
							 ^
	internal/utf8/encode.go:37:16: unnecessary conversion (unconvert)
			bits = uint64(t3 | (x>>(6*2))&mask3)
							 ^
	internal/utf8/encode.go:42:16: unnecessary conversion (unconvert)
			bits = uint64(t4 | (x>>(6*3))&mask4)
							 ^

* flac: fix golangci lint issues

	encode_frame.go:89:1: cyclomatic complexity 52 of func `(*Encoder).encodeFrameHeader` is high (> 30) (gocyclo)
	func (enc *Encoder) encodeFrameHeader(w io.Writer, hdr frame.Header) error {
	^
	internal/utf8/encode.go:66:17: unnecessary conversion (unconvert)
			bits := uint64(tx | (x>>uint(6*i))&maskx)
							  ^
	encode_subframe.go:105:46: unnecessary conversion (unconvert)
			if err := bw.WriteBits(uint64(sample), byte(hdr.BitsPerSample)); err != nil {
																	 ^

* flac: clarify that frame.Header.Num is calculated by the encoder

* flac: minor re-phrasing
2018-08-19 03:18:12 +09:00
mewmew 4309906bb8 frame: remove debug print of contiunation bytes
This has been tested with FLAC files containing
a lot of samples and a small block size, thus
having frame.Num make use of up to four
continuation bytes.
2018-08-19 04:21:43 +09:00
mewmew 8c556856f4 frame: make CRC mismatch warnings instead of fatal errors
Updates #31.
2018-08-19 03:50:28 +09:00
Henry Eklind 4d6d7bc3d0 Vendor our dependencies with vgo (#27)
* Vendor our dependencies with `vgo`

* flac: update go.mod
2018-08-17 03:16:13 +09:00
mewmew 3b70b1df45 flac: fix golangci metalint issues 2018-08-18 01:20:48 +09:00
mewmew da5a5e9313 cmd/flac2wav: update flac2wav to use go-audio instead of Azul3D 2018-08-18 01:09:46 +09:00
Henry Eklind d8cbdcb671
Merge pull request #28 from mdickers47/synchint
remove dependency on encodedbytes
2018-06-07 11:58:45 +09:00
Mikey Dickerson b3ae1b93a8 remove unnecessary conversion 2018-06-06 22:14:00 -04:00
Mikey Dickerson 147494a422 remove dependency on encodebytes 2018-06-06 22:05:04 -04:00
Henry Eklind fa00a54cd7
Merge pull request #26 from mewkiz/golangci
Add golangci metalinter
2018-05-28 10:48:39 +09:00
mewmew 8e870c4eed travis: add note to describe that G501 refers to blacklist of md5 check 2018-05-27 15:37:20 +02:00
mewmew 10505c0392 meta: simplify parseCueSheet by refactoring
Fixes lint issue reported by gocyclo:

meta/cuesheet.go:30:1: cyclomatic complexity 37 of func `(*Block).parseCueSheet` is high (> 30) (gocyclo)
func (block *Block) parseCueSheet() error {
^

Fixes #25.
2018-05-27 15:23:03 +02:00
mewmew 46e9cd6b14 frame: simplify parseHeader by refactoring
Fixes lint issue reported by gocyclo:

frame/frame.go:212:1: cyclomatic complexity 52 of func `(*Frame).parseHeader` is high (> 30) (gocyclo)
func (frame *Frame) parseHeader() error {
^

Updates #25.
2018-05-27 15:10:15 +02:00
mewmew f6859d9088 travis: skip maligned lint check
We want to keep the structures identical to spec
as they are used for parsing.
2018-05-27 14:43:04 +02:00
mewmew e8384a1c1b frame: use exclusion regexp instead of _ to skip error check of md5sum.Write and md5 import
golangci-lint run --enable-all -e "(Error return value of .md5sum\.Write. is not checked)"
2018-05-27 14:39:47 +02:00
mewmew 6d39a798cb cmd/go-metaflac: simplify control flow
Fix issue reported by megacheck:

cmd/go-metaflac/metaflac.go:82:2: unnecessary nil check around range (megacheck)
	if blockNums != nil {
	^

Updates #25.
2018-05-27 14:32:15 +02:00
mewmew 95b4b1d046 flac: fix issues reported by errcheck and unconvert
enc.go:178:35: unnecessary conversion (unconvert)
	if err := enc.bw.WriteBits(uint64(si.NSamples), 36); err != nil {
	                                 ^
enc.go:543:34: unnecessary conversion (unconvert)
	if _, err := enc.bw.Write([]byte(pic.Data)); err != nil {
	                                ^

frame/frame.go:161:17: Error return value of `md5sum.Write` is not checked (errcheck)
				md5sum.Write(buf[:1])
				            ^
frame/frame.go:165:17: Error return value of `md5sum.Write` is not checked (errcheck)
				md5sum.Write(buf[:2])
				            ^
frame/frame.go:170:17: Error return value of `md5sum.Write` is not checked (errcheck)
				md5sum.Write(buf[:])
				            ^

Updates #25.
2018-05-27 14:28:25 +02:00
mewmew e6f4bf95f2 frame: remove unused constant t1 used in UTF-8 decoding
frame/utf8.go:11:2: `t1` is unused (deadcode)
	t1 = 0x00 // 0000 0000

Updates #25.
2018-05-27 14:20:05 +02:00
mewmew 5955dc6a6b golangci: add golangci-lint 2018-05-26 11:30:21 +02:00
mewmew fcab6ed7a2 flac: minor update of comment 2018-05-25 18:15:07 +02:00
Henry Eklind 36cc17efed Skip ID3v2 data prepended to flac files on parsing (#21)
* Change signature to flacSignature

In order to disambiguate the introduction of the ID3v2 signature.

* Add check flac files containing ID3v2 data

* Implement skipId3v2

Note: a new import for decoding synchronized integers from ID3v2 headers
was introduced.

* Add error checking on the r.Discard calls

* Fix comments

* Use limited scope for error handling

* Capitalize ID in skipID3v2

* Fix comments

* Add testcase for skipping id3 data
2018-05-25 17:27:20 +02:00
Robin Eklind 50441e5efb
Fix Travis build (#23)
bump Go version to latest stable
2018-05-25 00:00:01 +02:00
mewmew ffd35219d3 flac: fix Close method to close underlying file descriptor 2018-04-08 17:47:05 +02:00
mewmew d1bcf309b2 Merge branch 'master' of github.com:mewkiz/flac 2017-12-26 15:14:36 +01:00
mewmew 9c66335d65 frame: fix typo reported by misspell 2017-12-26 15:14:11 +01:00
Robin Eklind d30adc1714 Merge pull request #18 from chewxy/master
Added 16kHz test file
2017-10-01 13:57:18 +02:00
chewxy 43fbacf007 Added 8297-275156-0011.flac, which is a 16kHz sampled file, derived from the LibriSpeech ASR corpus by Vassil Panayotov and Daniel Povey. The file is CCBY-4.0 2017-10-01 09:09:15 +11:00