Skip to content

Commit

Permalink
Merge pull request #18 from dpolakovics/add-volume-slider
Browse files Browse the repository at this point in the history
Add volume slider
  • Loading branch information
dpolakovics authored Dec 15, 2024
2 parents 5dbb334 + 41420f8 commit ffd8703
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 113 deletions.
2 changes: 2 additions & 0 deletions .chatgpt_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ project_name: "soundscape-sync"
default_prompt_blocks:
- "basic-prompt"
- "go-development"
initial_files:
- "README.md"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
./fyne-cross
fyne-cross
./soundscape-sync
10 changes: 5 additions & 5 deletions FyneApp.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Details]
Icon = "Icon.png"
Name = "SoundscapeSync"
ID = "com.cloonar.soundscape-sync"
Version = "0.0.1"
Build = 1
Icon = "Icon.png"
Name = "SoundscapeSync"
ID = "com.cloonar.soundscape-sync"
Version = "0.0.1"
Build = 2
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ It is important that both folders have the same amount of Files and that the fil
- [x] Make it possible to Sync with spatial Audio Soundscapes
- [ ] Make it usable with Mac
- [ ] Generate a package for Ubuntu
- [ ] Better handling of file mapping
- [x] add cover art for mp3
- [x] add cover art for m4b
- [x] load metadata from audiobook

## Support Me
Expand Down
10 changes: 4 additions & 6 deletions internal/logic/sync-5.1.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package logic

func get5_1Arguments() []string {
import "fmt"

func get5_1Arguments(volume float64) []string {
return []string{
// best audio format so far on ios
"-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2[out]",
"-filter_complex", fmt.Sprintf("[0:a]volume=%f,apad[a2];[1:a][a2]amerge=inputs=2[out]", volume),
"-c:a", "aac", "-b:a", "654k",
// mp4 output
// "-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=5.1|c0=c0+c6|c1=c1+c7|c2=c2|c3=c3|c4=c4|c5=c5[out]",
// "-c:a", "eac3", "-ac", "6",
}
}
6 changes: 4 additions & 2 deletions internal/logic/sync-7.1.2.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package logic

func get7_1_2Arguments() []string {
import "fmt"

func get7_1_2Arguments(volume float64) []string {
return []string{
"-filter_complex",
"[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=7.1.2|FL=c0+c10|FR=c1+c11|FC=c2|LFE=c3|BL=c6|BR=c7|SL=c4|SR=c5|TFL=c8|TFR=c9[out]",
fmt.Sprintf("[0:a]volume=%f,apad[a2];[1:a][a2]amerge=inputs=2,pan=7.1.2|FL=c0+c10|FR=c1+c11|FC=c2|LFE=c3|BL=c6|BR=c7|SL=c4|SR=c5|TFL=c8|TFR=c9[out]", volume),
}
}
6 changes: 4 additions & 2 deletions internal/logic/sync-7.1.4.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package logic

func get7_1_4Arguments() []string {
import "fmt"

func get7_1_4Arguments(volume float64) []string {
return []string{
"-filter_complex",
"[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=7.1.4|FL=c0+c12|FR=c1+c13|FC=c2|LFE=c3|BL=c6|BR=c7|SL=c4|SR=c5|TFL=c8|TFR=c9|TBL=c10|TBR=c11[out]",
fmt.Sprintf("[0:a]volume=%f,apad[a2];[1:a][a2]amerge=inputs=2,pan=7.1.4|FL=c0+c12|FR=c1+c13|FC=c2|LFE=c3|BL=c6|BR=c7|SL=c4|SR=c5|TFL=c8|TFR=c9|TBL=c10|TBR=c11[out]", volume),
}
}
6 changes: 4 additions & 2 deletions internal/logic/sync-stereo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package logic

func getStereoArguments() []string {
import "fmt"

func getStereoArguments(volume float64) []string {
return []string{
"-filter_complex", "[1:a]apad[a2];[0:a][a2]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[out]",
"-filter_complex", fmt.Sprintf("[0:a]volume=%f,apad[a2];[1:a][a2]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[out]", volume),
}
}
19 changes: 11 additions & 8 deletions internal/logic/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ func getAudioFiles(folder string) ([]string, error) {
return audioFiles, nil
}

func CombineFiles(folder1 string, folder2 string, outputFolder string, progress *widget.ProgressBar) error {
func CombineFiles(folder1 string, folder2 string, outputFolder string, progress *widget.ProgressBar, soundscapeVolume float64) error {
// Adjust volume to range [0.5, 1.0]
soundscapeVolume = 0.5 + (soundscapeVolume / 100.0 * 0.5)

// Get list of audio files from both folders
files1, err := getAudioFiles(folder1)
if err != nil {
Expand Down Expand Up @@ -69,11 +72,11 @@ func CombineFiles(folder1 string, folder2 string, outputFolder string, progress
return err
}

channelArguments, err := getChannelArguments(channel)
channelArguments, err := getChannelArguments(channel, soundscapeVolume)
if err != nil {
return err
}

// Get output file name
ext := filepath.Ext(file)
newFileName := outputFolder + "/" + filepath.Base(files2[index])
Expand Down Expand Up @@ -165,16 +168,16 @@ func getBaseArguments() []string {
}
}

func getChannelArguments(channels int) ([]string, error) {
func getChannelArguments(channels int, volume float64) ([]string, error) {
switch channels {
case 2:
return getStereoArguments(), nil
return getStereoArguments(volume), nil
case 6:
return get5_1Arguments(), nil
return get5_1Arguments(volume), nil
case 10:
return get7_1_2Arguments(), nil
return get7_1_2Arguments(volume), nil
case 12:
return get7_1_4Arguments(), nil
return get7_1_4Arguments(volume), nil
}
return nil, fmt.Errorf("Currently only stereo, 5.1, 7.1.2 and 7.1.4 Soundscapes are supported")
}
Expand Down
10 changes: 10 additions & 0 deletions internal/ui/sysproc_default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !windows
// +build !windows

package ui

import "syscall"

func getSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{}
}
16 changes: 16 additions & 0 deletions internal/ui/sysproc_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build windows
// +build windows

package ui

import (
"syscall"
)

const CREATE_NO_WINDOW = 0x08000000

func getSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{
CreationFlags: CREATE_NO_WINDOW,
}
}
Loading

0 comments on commit ffd8703

Please sign in to comment.