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):
self.Logger.info("~AudioClip()")
def Play(self, seconds = None, *args):
return self.AudioPlayer.PlayURI(self.URI, seconds, *args)
def Play(self, seconds = None, rubberband = None, *args):
return self.AudioPlayer.PlayURI(self.URI, seconds, rubberband = rubberband, *args)
def Stop(self):
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.Stop()
def PlayURI(self, uri, position, *args):
if 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, "-"]
else:
Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-vn", *args, "-"]
def PlayURI(self, uri, position, rubberband = None, *args):
if 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]
else:
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
asyncio.ensure_future(self._stream_subprocess(Command))
return True
self.Playing = True
if rubberband:
Command += ["-filter:a"]
rubberCommand = ""
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):
if not self.Playing: