| 1 |
#!/usr/bin/env python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# #################################################################### |
| 5 |
# Copyright (C) 2005-2019 by the FIFE team |
| 6 |
# http://www.fifengine.net |
| 7 |
# This file is part of FIFE. |
| 8 |
# |
| 9 |
# FIFE is free software; you can redistribute it and/or |
| 10 |
# modify it under the terms of the GNU Lesser General Public |
| 11 |
# License as published by the Free Software Foundation; either |
| 12 |
# version 2.1 of the License, or (at your option) any later version. |
| 13 |
# |
| 14 |
# This library is distributed in the hope that it will be useful, |
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
# Lesser General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU Lesser General Public |
| 20 |
# License along with this library; if not, write to the |
| 21 |
# Free Software Foundation, Inc., |
| 22 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 |
# #################################################################### |
| 24 |
|
| 25 |
import time |
| 26 |
from .swig_test_utils import * |
| 27 |
from fife.extensions import fifelog |
| 28 |
|
| 29 |
class TestAudio(unittest.TestCase): |
| 30 |
|
| 31 |
def setUp(self): |
| 32 |
self.engine = getEngine(True) |
| 33 |
self.soundmanager = self.engine.getSoundManager() |
| 34 |
self.soundclipmanager = self.engine.getSoundClipManager() |
| 35 |
self.log = fifelog.LogManager(self.engine, promptlog=True, filelog=False) |
| 36 |
self.log.setVisibleModules('resource manager', 'audio') |
| 37 |
self.soundmanager.init() |
| 38 |
|
| 39 |
def tearDown(self): |
| 40 |
self.engine.destroy() |
| 41 |
del self.log |
| 42 |
|
| 43 |
def testLeftRight(self): |
| 44 |
sound = self.soundmanager.createEmitter('tests/data/left_right_test.ogg') |
| 45 |
sound.setLooping(True) |
| 46 |
sound.play() |
| 47 |
time.sleep(3); |
| 48 |
|
| 49 |
def test2Streams(self): |
| 50 |
em = self.soundmanager.createEmitter() |
| 51 |
sound = self.soundmanager.createEmitter() |
| 52 |
clip = self.soundclipmanager.load('tests/data/left_right_test.ogg') |
| 53 |
sound.setSoundClip(clip) |
| 54 |
sound.setLooping(True) |
| 55 |
sound.setCursor(fife.SD_TIME_POS, 5) |
| 56 |
em.setSoundClip(clip) |
| 57 |
em.setGain(0.7) |
| 58 |
em.play() |
| 59 |
sound.play() |
| 60 |
time.sleep(3); |
| 61 |
|
| 62 |
TEST_CLASSES = [TestAudio] |
| 63 |
|
| 64 |
if __name__ == '__main__': |
| 65 |
unittest.main() |