summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rhimport/conf.go2
-rw-r--r--rhimport/converter.go19
-rw-r--r--rhimport/core.go2
-rw-r--r--rhimport/fetcher.go15
4 files changed, 24 insertions, 14 deletions
diff --git a/rhimport/conf.go b/rhimport/conf.go
index b7e8f88..942bb62 100644
--- a/rhimport/conf.go
+++ b/rhimport/conf.go
@@ -44,7 +44,7 @@ func NewConfig(rdxportEndpoint, tempDir, localFetchDir string) (conf *Config) {
conf.TempDir = tempDir
conf.LocalFetchDir = localFetchDir
conf.ImportParamDefaults.Channels = 2
- conf.ImportParamDefaults.NormalizationLevel = -12
+ conf.ImportParamDefaults.NormalizationLevel = 0
conf.ImportParamDefaults.AutotrimLevel = 0
conf.ImportParamDefaults.UseMetaData = true
return
diff --git a/rhimport/converter.go b/rhimport/converter.go
index e8e693f..d375ad0 100644
--- a/rhimport/converter.go
+++ b/rhimport/converter.go
@@ -36,12 +36,13 @@ import (
type FetchConverter interface {
io.WriteCloser
- GetResult() (result string, err error)
+ GetResult() (result string, err error, loudnessCorr float64)
}
type ConverterResult struct {
- output string
- err error
+ output string
+ err error
+ loudnessCorr float64
}
func NewFetchConverter(convType, filename string, metadata map[string]string) (FetchConverter, string, error) {
@@ -78,8 +79,8 @@ func (c *NullFetchConverter) Close() (err error) {
return c.file.Close()
}
-func (c *NullFetchConverter) GetResult() (result string, err error) {
- return "", nil
+func (c *NullFetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
+ return "", nil, 0.0
}
//
@@ -111,7 +112,7 @@ func NewFFMpegFetchConverter(filename string, metadata map[string]string) (ff *F
ff.result = make(chan ConverterResult, 1)
go func() {
output, err := ff.cmd.CombinedOutput()
- ff.result <- ConverterResult{strings.TrimSpace(string(output)), err}
+ ff.result <- ConverterResult{strings.TrimSpace(string(output)), err, 0.0}
}()
return
}
@@ -124,10 +125,10 @@ func (ff *FFMpegFetchConverter) Close() (err error) {
return ff.pipe.Close()
}
-func (ff *FFMpegFetchConverter) GetResult() (result string, err error) {
+func (ff *FFMpegFetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
if ff.result != nil {
r := <-ff.result
- return r.output, r.err
+ return r.output, r.err, r.loudnessCorr
}
- return "", nil
+ return "", nil, 0.0
}
diff --git a/rhimport/core.go b/rhimport/core.go
index 0e596ba..5dd0355 100644
--- a/rhimport/core.go
+++ b/rhimport/core.go
@@ -134,6 +134,7 @@ type Context struct {
DeleteSourceFile bool
DeleteSourceDir bool
SourceFilePolicy FilePolicy
+ LoudnessCorr float64
ProgressCallBack ProgressCB
ProgressCallBackData interface{}
Cancel <-chan bool
@@ -162,6 +163,7 @@ func NewContext(conf *Config, db *rddb.DBChan) *Context {
ctx.SourceFile = ""
ctx.DeleteSourceFile = false
ctx.DeleteSourceDir = false
+ ctx.LoudnessCorr = 0.0
ctx.SourceFilePolicy = Auto
ctx.ProgressCallBack = nil
ctx.Cancel = nil
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go
index f40adca..74cd1fa 100644
--- a/rhimport/fetcher.go
+++ b/rhimport/fetcher.go
@@ -176,7 +176,7 @@ func fetchFileCurl(ctx *Context, res *Result, uri *url.URL) (err error) {
if cbdata.conv != nil {
cbdata.conv.Close()
rhl.Printf("waiting for converter to finish...")
- convOut, convErr = cbdata.conv.GetResult()
+ convOut, convErr, ctx.LoudnessCorr = cbdata.conv.GetResult()
}
if err != nil || cbdata.writeError != nil || convErr != nil {
if cbdata.conv != nil {
@@ -204,6 +204,7 @@ func fetchFileCurl(ctx *Context, res *Result, uri *url.URL) (err error) {
rhl.Println(err)
return
}
+ rhdl.Printf("converter: loudness correction = %.2f dB", ctx.LoudnessCorr)
ctx.SourceFile = cbdata.filename
if ctx.SourceFilePolicy == Auto {
@@ -306,7 +307,7 @@ func fetchFileArchiv(ctx *Context, res *Result, uri *url.URL) (err error) {
if cbdata.conv != nil {
cbdata.conv.Close()
rhl.Printf("waiting for converter to finish...")
- convOut, convErr = cbdata.conv.GetResult()
+ convOut, convErr, ctx.LoudnessCorr = cbdata.conv.GetResult()
}
if err != nil || cbdata.writeError != nil || convErr != nil {
if cbdata.conv != nil {
@@ -329,6 +330,7 @@ func fetchFileArchiv(ctx *Context, res *Result, uri *url.URL) (err error) {
rhl.Println(err)
return
}
+ rhdl.Printf("converter: loudness correction = %.2f dB", ctx.LoudnessCorr)
ctx.SourceFile = cbdata.filename
if ctx.SourceFilePolicy == Auto {
@@ -392,12 +394,15 @@ func fetchFileDirConvert(ctx *Context, res *Result, origSrc *os.File, sizeTotal
conv.Close()
rhl.Printf("waiting for converter to finish...")
- if convOut, convErr := conv.GetResult(); convErr != nil {
+ var convOut string
+ var convErr error
+ if convOut, convErr, ctx.LoudnessCorr = conv.GetResult(); convErr != nil {
if convOut != "" {
rhl.Printf("converter error: %v; converter output: %s", convErr, convOut)
}
return fmt.Errorf("converter error: %v; converter output: %s", convErr, convOut)
}
+ rhdl.Printf("converter: loudness correction = %.2f dB", ctx.LoudnessCorr)
if err != nil {
return err
}
@@ -607,7 +612,7 @@ func fetchFileAttachment(ctx *Context, res *Result, uri *url.URL) error {
err = writeAttachmentFile(ctx, res, sizeTotal, conv)
conv.Close()
rhl.Printf("waiting for converter to finish...")
- convOut, convErr := conv.GetResult()
+ convOut, convErr, loudnessCorr := conv.GetResult()
if err != nil {
return err
}
@@ -617,6 +622,8 @@ func fetchFileAttachment(ctx *Context, res *Result, uri *url.URL) error {
}
return fmt.Errorf("converter error: %v; converter output: %s", convErr, convOut)
}
+ ctx.LoudnessCorr = loudnessCorr
+ rhdl.Printf("converter: loudness correction = %.2f dB", ctx.LoudnessCorr)
if ctx.SourceFilePolicy == Auto {
ctx.DeleteSourceFile = true