Documentation
¶
Overview ¶
Example (ResamplingFile) ¶
package main import ( "gitlab.com/gunter-go/resample" "io" "os" ) func main() { input, _ := os.Open("./original.raw") output, _ := os.Create("./resampled.raw") res, _ := resample.New(output, resample.FormatInt16, 48000, 16000, 2) _, _ = io.Copy(res, input) }
Example (ResamplingSlice) ¶
package main import ( "bytes" "encoding/binary" "fmt" "gitlab.com/gunter-go/resample" ) func main() { // Convert slice of values into a slice of bytes input := []int16{1, 3, 5} inputData := new(bytes.Buffer) _ = binary.Write(inputData, binary.LittleEndian, input) // Resample outBuf := new(bytes.Buffer) res, _ := resample.New(outBuf, resample.FormatInt16, 1, 2, 1, resample.WithLinearFilter()) _, _ = res.Write(inputData.Bytes()) // Convert bytes back to a slice of values output := make([]int16, 5) _ = binary.Read(outBuf, binary.LittleEndian, output) fmt.Println(output) }
Output: [1 2 3 4 5]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is a struct used to configure Resampler.
func WithKaiserBestFilter ¶
func WithKaiserBestFilter() Option
WithKaiserBestFilter function returns option that configures Resampler to use the fastest Kaiser filter.
Used by default.
func WithKaiserFastFilter ¶
func WithKaiserFastFilter() Option
WithKaiserFastFilter function returns option that configures Resampler to use the best Kaiser filter.
Best Kaiser filter provides higher resampling speed in exchange for lower quality.
func WithKaiserFastestFilter ¶
func WithKaiserFastestFilter() Option
WithKaiserFastestFilter function returns option that configures Resampler to use the fast Kaiser filter.
Fastest Kaiser filter provides higher resampling speed in exchange for lower quality.
func WithLinearFilter ¶
func WithLinearFilter() Option
WithLinearFilter function returns option that configures Resampler to use linear filter.
This option should be used only for testing purposes because linear filter provides poor resampling quality.
func WithNoMemoization ¶
func WithNoMemoization() Option
WithNoMemoization function returns option that disables memoization in Resampler.
This option should be used when Resampler consumers too much memory. Such behaviour may occur when resampling between sampling rages with a small greatest common divisor (e.g. 9999 and 10000).
Enabling this function slows the resampling progress significantly. Therefore, Most users should avoid it and should switch used filter instead.
type Resampler ¶
type Resampler struct {
// contains filtered or unexported fields
}
A Resampler is an object that writes resampled data into an io.Writer.
func New ¶
func New(outBuffer io.Writer, format Format, inRate, outRate, ch int, options ...Option) (*Resampler, error)
New creates a new Resampler.
Default filter is kaiser fast filter, use WithXFilter options to change it. Memoization is enabled by default, use WithNoMemoization function to disable it.