示例#1
0
def fmod_version():
    """FMOD API version number."""
    system = pyfmodex.System()
    version = system.version
    system.close()
    system.release()
    return version
示例#2
0
 def init():
     """
     inits the system from FMOD
     """
     if FMOD._system == None:
         FMOD._system = pyfmodex.System()
         FMOD._system.init()
         FMOD._threedSettings = FMOD._system.threed_settings
示例#3
0
def main(argv):
	system = fmod.System()
	num_drivers = system.num_drivers
	for i in range(num_drivers):
		d = system.get_driver_info(i)
		vals = {}
		for key in d.keys():
			vals[key] = d[key]
		print("driver", vals)

	system.init()

	sounds = []
	for root, dirs, files in os.walk('./media'):
		for f in files:
			file = os.path.join(root, f)

			sound = system.create_sound(file, fmod.flags.MODE.ACCURATETIME)
			format = sound.format
			attrs = {
				'type': format.type,
				'channels': format.channels,
				'format': format.format,
				'length': sound.get_length(fmod.flags.TIMEUNIT.MS)
			}

			print(len(sounds), ':', file, attrs)

			sounds.append({
				'sound': sound,
				'attrs': attrs
			})

	master_group = system.master_channel_group

	sound_group = system.create_channel_group('sound')
	left_group = system.create_channel_group('left')
	right_group = system.create_channel_group('right')

	left_group.add_group(sound_group, True)
	left_group.set_mix_matrix([0, 1, 0, 0], 2, 2)
	#right_group.add_group(sound_group, True)
	#right_group.set_mix_matrix([0, 0, 1, 0], 2, 2)

	#left_group.volume = .3
	#right_group.volume = .3

	parent = sound_group.parent_group
	print('parent name', parent.name)
	print('parent is master', parent is master_group)

	s = sounds[1]['sound']
	channel = s.play(sound_group)

	while channel.is_playing:
		time.sleep(0)

	return 0
示例#4
0
def init():
    global ssound
    pygame.mixer.pre_init(44100, -16, 2)
    try:
        ssound = fmod.System()
        ssound.init()
    except ValueError as e:
        print("[REE] Impossible de charger FMODEX\n[REE] - Err: %s" % e)
    return pygame.init()
示例#5
0
    def __init__(self, num_speakers, logger=default_logger):
        self.num_speakers = num_speakers
        self.speakers = SpeakerGroup([Speaker(i) for i in range(num_speakers)])
        self.logger = logger

        self.running = False

        self.fmod_system = fmod.System()
        self.output = None

        format = self.fmod_system.software_format
        format.raw_speakers = num_speakers
        format.speaker_mode = fmod.enums.SPEAKERMODE.RAW.value
        self.fmod_system.software_format = format
示例#6
0
"""Sample code to show basic positioning of 3D sounds."""

import curses
import sys
import time
from math import sin

import pyfmodex
from pyfmodex.flags import MODE

INTERFACE_UPDATETIME = 50
DISTANCEFACTOR = 1
MIN_FMOD_VERSION = 0x00020108

# Create system object and initialize
system = pyfmodex.System()
VERSION = system.version
if VERSION < MIN_FMOD_VERSION:
    print(f"FMOD lib version {VERSION:#08x} doesn't meet "
          f"minimum requirement of version {MIN_FMOD_VERSION:#08x}")
    sys.exit(1)

system.init(maxchannels=3)

THREED_SETTINGS = system.threed_settings
THREED_SETTINGS.distance_factor = DISTANCEFACTOR

# Load some sounds
sound1 = system.create_sound("media/drumloop.wav", mode=MODE.THREED)
sound1.min_distance = 0.5 * DISTANCEFACTOR
sound1.max_distance = 5000 * DISTANCEFACTOR
示例#7
0
def fmod_version():
    system = pyfmodex.System()
    version = system.version
    system.close()
    return version
示例#8
0
def initialized_system():
    system = pyfmodex.System()
    system.init()
    yield system
    system.close()
    system.release()
示例#9
0
def system():
    system = pyfmodex.System()
    yield system
    system.release()
示例#10
0
def many_speakers_system():
    system = pyfmodex.System()
    format = system.software_format
    format.speaker_mode = SPEAKERMODE.SEVENPOINTONE
    system.software_format = format
    yield system
示例#11
0
def many_speakers_system():
    system = pyfmodex.System()
    format = system.software_format
    format.speaker_mode = 7
    system.software_format = format
    yield system
示例#12
0
def main(stdscr):
    """Draw a simple TUI, grab keypresses and let the user play some sounds."""
    stdscr.clear()
    stdscr.nodelay(True)

    # Create small visual display
    stdscr.addstr(
        "========================\n"
        "Multiple System Example.\n"
        "========================"
    )

    # Create Sound Card A
    system_a = pyfmodex.System()
    version = system_a.version
    if version < MIN_FMOD_VERSION:
        print(
            f"FMOD lib version {version:#08x} doesn't meet "
            f"minimum requirement of version {MIN_FMOD_VERSION:#08x}"
        )
        sys.exit(1)

    system_a.driver = fetch_driver(stdscr, system_a, "System A")
    system_a.init()

    # Create Sound Card B
    system_b = pyfmodex.System()
    system_b.driver = fetch_driver(stdscr, system_b, "System B")
    system_b.init()

    # Load one sample into each sound card
    sound_a = system_a.create_sound("media/drumloop.wav", mode=MODE.LOOP_OFF)
    sound_b = system_b.create_sound("media/jaguar.wav")

    stdscr.move(4, 0)
    stdscr.clrtobot()
    stdscr.addstr(
        "Press 1 to play a sound on device A\n"
        "Press 2 to play a sound on device B\n"
        "Press q to quit"
    )
    while True:
        stdscr.move(8, 0)
        stdscr.clrtobot()
        stdscr.addstr(
            f"Channels playing on A: {system_a.channels_playing.channels}\n"
            f"Channels playing on B: {system_b.channels_playing.channels}"
        )

        # Listen to the user
        try:
            keypress = stdscr.getkey()
            if keypress == "1":
                system_a.play_sound(sound_a)
            elif keypress == "2":
                system_b.play_sound(sound_b)
            elif keypress == "q":
                break
        except curses.error as cerr:
            if cerr.args[0] != "no input":
                raise cerr

        system_a.update()
        system_b.update()
        time.sleep(50 / 1000)

    # Shut down
    sound_a.release()
    system_a.release()

    sound_b.release()
    system_b.release()
示例#13
0
文件: box.py 项目: Marocco2/BoxRadio
                    if state == False:
                        self._play_event.set()
                    return 1  # mp3 loaded
                else:
                    ac.log('BOX: File not found : %s' % filename)
        except:
            ac.log('BOX: queueSong() error ' + traceback.format_exc())

    def lenQueue(self):
        leng = self.queue.__len__()
        return leng

    def _worker(self):
        while True:
            self._play_event.wait()
            queue_len = len(self.queue)
            while queue_len > 0:
                self.player.play_sound(self.queue[0]['sound'], False, 0)
                self.channel.spectrum_mix = self.speaker_mix
                self.channel.volume = self.playbackvol
                self.player.update()
                while self.channel.paused == 0 and self.channel.is_playing == 1:
                    time.sleep(0.1)
                self.queue[0]['sound'].release()
                self.queue.pop(0)
                queue_len = len(self.queue)
            self._play_event.clear()


FModSystem = pyfmodex.System()