()
| 46 | } |
| 47 | |
| 48 | func (sound *Sound) ReloadStream() { |
| 49 | |
| 50 | // if globals.Settings.Get(SettingsCacheAudioBeforePlayback).AsBool() { |
| 51 | |
| 52 | // ogStream := sound.Stream |
| 53 | |
| 54 | // // globals.EventLog.Log("caching audio", false) |
| 55 | |
| 56 | // buffer := beep.NewBuffer(sound.Format) |
| 57 | // buffer.Append(ogStream) |
| 58 | // sound.Stream = buffer.Streamer(0, ogStream.Len()) |
| 59 | |
| 60 | // // Close the stream if possible before replacing it, we don't need it after buffering |
| 61 | // if stream, ok := ogStream.(beep.StreamSeekCloser); ok { |
| 62 | // stream.Close() |
| 63 | // } |
| 64 | |
| 65 | // } |
| 66 | |
| 67 | resampled := beep.Resample(3, sound.Format.SampleRate, globals.ChosenAudioSampleRate, sound.Stream) |
| 68 | |
| 69 | seq := beep.Seq(resampled, beep.Callback(func() { |
| 70 | sound.Empty = true |
| 71 | })) |
| 72 | |
| 73 | sound.control = &beep.Ctrl{ |
| 74 | Streamer: seq, |
| 75 | Paused: true, |
| 76 | } |
| 77 | |
| 78 | sound.volume = &effects.Volume{ |
| 79 | Streamer: sound.control, |
| 80 | Volume: 0, |
| 81 | Base: 100, |
| 82 | Silent: false, |
| 83 | } |
| 84 | |
| 85 | sound.UpdateVolume() |
| 86 | |
| 87 | } |
| 88 | |
| 89 | func (sound *Sound) UpdateVolume() { |
| 90 | speaker.Lock() |
no test coverage detected