Commits

uniqx committed c0434a4

pyside algorithmic music example in progress

Comments (0)

Files changed (1)

examples/pyside-algorithmic-music/mu.py

+
+
+if __name__ == '__pyld_init__':
+
+  # imports
+
+  import random
+  import threading
+  import PySide.QtCore
+  import PySide.QtMultimedia
+
+  # qt audio buffer
+  audioBuffer = PySide.QtCore.QBuffer()
+
+  # start qt in a separate thread
+
+  PySide.QtCore.QThread(
+    PySide.QtCore.QCoreApplication(''))
+
+  # pyside audio setup
+
+  audioFormat = PySide.QtMultimedia.QAudioFormat()
+  audioFormat.setFrequency(8000)
+  audioFormat.setChannels(1)
+  audioFormat.setSampleSize(8)
+  audioFormat.setCodec('audio/pcm')
+  audioFormat.setByteOrder(PySide.QtMultimedia.QAudioFormat.LittleEndian)
+  audioFormat.setSampleType(PySide.QtMultimedia.QAudioFormat.UnSignedInt)
+
+  info = PySide.QtMultimedia.QAudioDeviceInfo(
+    PySide.QtMultimedia.QAudioDeviceInfo.defaultOutputDevice())
+  if not info.isFormatSupported(audioFormat):
+    print 'raw audio format not supported by backend, cannot play audio.'
+  else:
+    print 'PySide accepted specified audio fromat.'
+
+  audioOut = PySide.QtMultimedia.QAudioOutput(audioFormat)
+  audioOut.start(audioBuffer)
+
+if __name__ == '__pyld_reload__':
+
+  print '__pyld_reload__'
+
+  audioBuffer.setData('adijofpeoiqjfoijpkj')
+
+if __name__ == '__pyld_tick__':
+  pass
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.