diff --git a/model/settings.go b/model/settings.go
index fb9a02e..c2440a2 100644
--- a/model/settings.go
+++ b/model/settings.go
@@ -16,6 +16,7 @@ type Settings struct {
PreAlarmAction string `json:"pre_alarm_action"`
MaxRunTime time.Duration `json:"max_run_time"`
MaxVolume uint16 `json:"max_volume"`
+ StartVolume uint16 `json:"start_volume"`
Federation map[string]FederationServer `json:"federation"`
}
diff --git a/player/player.go b/player/player.go
index b493953..ff9c121 100644
--- a/player/player.go
+++ b/player/player.go
@@ -22,6 +22,7 @@ type Player struct {
Playlist []string
MaxRunTime time.Duration
MaxVolume uint16
+ StartVolume uint16
Stopper chan bool
currentCmd *exec.Cmd
currentCmdCh chan bool
@@ -95,6 +96,7 @@ func NewPlayer(cfg *config.Config, routines []reveil.Identifier) (*Player, error
currentCmdCh: make(chan bool, 1),
MaxRunTime: settings.MaxRunTime * time.Minute,
MaxVolume: uint16(settings.MaxVolume),
+ StartVolume: uint16(settings.StartVolume),
weatherTime: settings.WeatherDelay * time.Minute,
weatherAction: wact,
claironTime: settings.GongInterval * time.Minute,
@@ -204,7 +206,7 @@ loop:
} else {
p.dontUpdateVolume = false
p.volume = uint16(math.Log(1+float64(p.ntick)/8) * 9500)
- p.SetVolume(p.volume)
+ p.SetVolume(p.StartVolume + p.volume)
if p.reverseOrder {
p.playedItem -= 1
@@ -226,7 +228,7 @@ loop:
p.ntick += 1
if !p.dontUpdateVolume {
p.volume = 3500 + uint16(math.Log(1+float64(p.ntick)/8)*9500)
- p.SetVolume(p.volume)
+ p.SetVolume(p.StartVolume + p.volume)
}
case <-p.Stopper:
@@ -249,8 +251,12 @@ loopcalm:
for i := 0; i < 128 && p.volume >= 768; i += 1 {
timer := time.NewTimer(40 * time.Millisecond)
- p.volume -= 768
- p.SetVolume(p.volume)
+ if p.volume <= 0 {
+ p.StartVolume -= 768
+ } else {
+ p.volume -= 768
+ }
+ p.SetVolume(p.StartVolume + p.volume)
select {
case <-p.Stopper:
diff --git a/ui/src/lib/settings.js b/ui/src/lib/settings.js
index 064cd9a..2776d0f 100644
--- a/ui/src/lib/settings.js
+++ b/ui/src/lib/settings.js
@@ -5,7 +5,7 @@ export class Settings {
}
}
- update({ language, gong_interval, weather_delay, weather_action, pre_alarm_delay, pre_alarm_action, max_run_time, max_volume, federation }) {
+ update({ language, gong_interval, weather_delay, weather_action, pre_alarm_delay, pre_alarm_action, max_run_time, max_volume, start_volume, federation }) {
this.language = language;
this.gong_interval = gong_interval;
this.weather_delay = weather_delay;
@@ -14,6 +14,7 @@ export class Settings {
this.pre_alarm_action = pre_alarm_action;
this.max_run_time = max_run_time;
this.max_volume = max_volume;
+ this.start_volume = start_volume;
this.federation = federation;
}
diff --git a/ui/src/routes/settings/+page.svelte b/ui/src/routes/settings/+page.svelte
index d3c6911..4183486 100644
--- a/ui/src/routes/settings/+page.svelte
+++ b/ui/src/routes/settings/+page.svelte
@@ -160,6 +160,20 @@
+
+
+
+ submitSettings(settings)}
+ />
+
+
+