adding support for pitch and tempo commands on torchlight through rubberband

This commit is contained in:
jenz 2024-08-05 16:28:51 +02:00
parent f420bfc7ed
commit dc8b4badd0
3 changed files with 697 additions and 670 deletions

View File

@ -303,8 +303,8 @@ class AudioClip():
def __del__(self): def __del__(self):
self.Logger.info("~AudioClip()") self.Logger.info("~AudioClip()")
def Play(self, seconds = None, *args): def Play(self, seconds = None, rubberband = None, *args):
return self.AudioPlayer.PlayURI(self.URI, seconds, *args) return self.AudioPlayer.PlayURI(self.URI, seconds, rubberband = rubberband, *args)
def Stop(self): def Stop(self):
return self.AudioPlayer.Stop() return self.AudioPlayer.Stop()

File diff suppressed because it is too large Load Diff

View File

@ -57,18 +57,24 @@ class FFmpegAudioPlayer():
self.Master.Logger.debug("~FFmpegAudioPlayer()") self.Master.Logger.debug("~FFmpegAudioPlayer()")
self.Stop() self.Stop()
def PlayURI(self, uri, position, *args): def PlayURI(self, uri, position, rubberband = None, *args):
if position: if position:
PosStr = str(datetime.timedelta(seconds = position)) PosStr = str(datetime.timedelta(seconds = position))
Command = ["/usr/bin/ffmpeg", "-ss", PosStr, "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args, "-"] Command = ["/usr/bin/ffmpeg", "-ss", PosStr, "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args]
else: else:
Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args, "-"] Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args]
print(Command) self.Playing = True
if rubberband:
self.Playing = True Command += ["-filter:a"]
asyncio.ensure_future(self._stream_subprocess(Command)) rubberCommand = ""
return True for rubber in rubberband:
rubberCommand += rubber + ", "
rubberCommand = rubberCommand[:-2]
Command += [rubberCommand]
Command += ["-"]
asyncio.ensure_future(self._stream_subprocess(Command))
return True
def Stop(self, force = True): def Stop(self, force = True):
if not self.Playing: if not self.Playing: