[audiofuckuo solved]
This commit is contained in:
parent
dc180d3309
commit
30717ed97a
@ -1,7 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtMultimedia import QSound
|
from PyQt5.QtMultimedia import QMediaContent
|
||||||
|
from PyQt5.QtCore import QUrl
|
||||||
|
|
||||||
organization = "bendalab"
|
organization = "bendalab"
|
||||||
application = "blipblop"
|
application = "blipblop"
|
||||||
@ -32,7 +33,7 @@ def get_sound(name):
|
|||||||
if name in SNDS_DICT.keys():
|
if name in SNDS_DICT.keys():
|
||||||
print(name)
|
print(name)
|
||||||
print(SNDS_DICT[name])
|
print(SNDS_DICT[name])
|
||||||
return QSound(SNDS_DICT[name])
|
return QMediaContent(QUrl.fromLocalFile(os.path.abspath(SNDS_DICT[name])))
|
||||||
else:
|
else:
|
||||||
print("Sound %s not found!" % name)
|
print("Sound %s not found!" % name)
|
||||||
return None
|
return None
|
||||||
|
@ -121,7 +121,8 @@ class AudioBlop(QWidget):
|
|||||||
self._trial_counter = 0
|
self._trial_counter = 0
|
||||||
self._session_running = False
|
self._session_running = False
|
||||||
self._trial_running = False
|
self._trial_running = False
|
||||||
|
self._player = QMediaPlayer()
|
||||||
|
|
||||||
self.setFocus()
|
self.setFocus()
|
||||||
|
|
||||||
def create_actions(self):
|
def create_actions(self):
|
||||||
@ -181,15 +182,7 @@ class AudioBlop(QWidget):
|
|||||||
self._draw_area.setPixmap(self._canvas)
|
self._draw_area.setPixmap(self._canvas)
|
||||||
|
|
||||||
def blip(self):
|
def blip(self):
|
||||||
player = QMediaPlayer()
|
self._player.play()
|
||||||
url = QUrl.fromLocalFile("/home/grewe/projects/programming/blipblop/sounds/message.wav")
|
|
||||||
print(url)
|
|
||||||
content = QMediaContent(url)
|
|
||||||
print(content)
|
|
||||||
player.setMedia(content)
|
|
||||||
#player.setMedia( QUrl.fromLocalFile("/home/grewe/projects/programming/blipblop/sounds/message.wav"));
|
|
||||||
player.setVolume(100)
|
|
||||||
player.play()
|
|
||||||
# print(QAudioDeviceInfo.availableDevices(QAudio.AudioOutput))
|
# print(QAudioDeviceInfo.availableDevices(QAudio.AudioOutput))
|
||||||
#bells = cnst.get_sound("message")
|
#bells = cnst.get_sound("message")
|
||||||
#bells.setLoops(10)
|
#bells.setLoops(10)
|
||||||
@ -220,7 +213,12 @@ class AudioBlop(QWidget):
|
|||||||
return
|
return
|
||||||
self._trial_counter += 1
|
self._trial_counter += 1
|
||||||
self._status_label.setText("Trial %i of %i running" % (self._trial_counter, self._settings.trials))
|
self._status_label.setText("Trial %i of %i running" % (self._trial_counter, self._settings.trials))
|
||||||
self.setStatusTip("Test")
|
|
||||||
|
url = QUrl.fromLocalFile("/home/grewe/projects/programming/blipblop/sounds/message.wav")
|
||||||
|
content = cnst.get_sound("message")
|
||||||
|
self._player.setMedia(content)
|
||||||
|
self._player.setVolume(100)
|
||||||
|
|
||||||
min_interval = int(self._settings.min_delay / 100)
|
min_interval = int(self._settings.min_delay / 100)
|
||||||
max_interval = int(self._settings.max_delay / 100)
|
max_interval = int(self._settings.max_delay / 100)
|
||||||
interval = np.random.randint(min_interval, max_interval, 1) * 100
|
interval = np.random.randint(min_interval, max_interval, 1) * 100
|
||||||
|
Loading…
Reference in New Issue
Block a user