コード例 #1
0
ファイル: mixer.py プロジェクト: jggatc/pyj2d
 def get_length(self):
     """
     Get length of sound sample.
     """
     stream = AudioSystem.getAudioInputStream(self._sound_object)
     length = stream.getFrameLength() / stream.getFormat().getFrameRate()
     stream.close()
     return length
コード例 #2
0
ファイル: common.py プロジェクト: miklobit/ScratchToCatrobat
def length_of_audio_file_in_secs(file_path):
    audioInputStream = AudioSystem.getAudioInputStream(java.io.File(file_path))
    format_ = audioInputStream.getFormat()
    frames = audioInputStream.getFrameLength()
    return float(frames) / format_.getFrameRate()
コード例 #3
0
ファイル: mixer.py プロジェクト: jggatc/pyj2d
 def _set_sound(self, sound):
     self._sound = sound
     self._stream = AudioSystem.getAudioInputStream(sound._sound_object)
コード例 #4
0
from java.io import File
from javax.sound.sampled import AudioInputStream
from javax.sound.sampled import AudioSystem
from javax.sound.sampled import Clip
from java.lang import Thread, Runnable

file = File(
    "C:\\Users\\Sony\\Desktop\\jython-prac-prog\\network\\sample_audio.wav")
stream = AudioSystem.getAudioInputStream(file)
clip = AudioSystem.getClip()
print(type(clip))


class f(Runnable):
    def __init__(self, x):
        self.x = x

    def run(self):

        self.x.open(stream)
        self.x.start()


g = f(clip)
k = Thread(g)
k.start()
Thread.sleep(500)
print("End")
#Thread.sleep(35000)
stream.close()
コード例 #5
0
 def _get_stream(self):
     if isinstance(self._sound_object, File):
         return AudioSystem.getAudioInputStream(self._sound_object)
     else:
         return ByteArrayInputStream(self._sound_object)
コード例 #6
0
 def _get_sound_object(self, sound_file):
     stream = AudioSystem.getAudioInputStream(sound_file)
     sound_object = jarray.zeros(stream.available(), 'b')
     stream.read(sound_object)
     stream.close()
     return sound_object
コード例 #7
0
def length_of_audio_file_in_secs(file_path):
    audioInputStream = AudioSystem.getAudioInputStream(java.io.File(file_path))
    format_ = audioInputStream.getFormat()
    frames = audioInputStream.getFrameLength()
    return float(frames) / format_.getFrameRate()