2
# -*- coding: utf-8 -*-
4
# pySFML - Python bindings for SFML
5
# Copyright 2012-2013, Jonathan De Wachter <dewachter.jonathan@gmail.com>
7
# This software is released under the LGPLv3 license.
8
# You should have received a copy of the GNU Lesser General Public License
9
# along with this program. If not, see <http://www.gnu.org/licenses/>.
14
# load a sound buffer from a wav file
15
buffer = sf.SoundBuffer.from_file("data/canary.wav")
17
# display sound informations
19
print("{0} seconds".format(buffer.duration))
20
print("{0} samples / sec".format(buffer.sample_rate))
21
print("{0} channels".format(buffer.channel_count))
23
# create a sound instance and play it
24
sound = sf.Sound(buffer)
27
# loop while the sound is playing
28
while sound.status == sf.Sound.PLAYING:
29
# leave some CPU time for other processes
30
sf.sleep(sf.milliseconds(100))
33
# load an ogg music file
34
music = sf.Music.from_file("data/orchestral.ogg")
36
# display music informations
37
print("orchestral.ogg:")
38
print("{0} seconds".format(music.duration))
39
print("{0} samples / sec".format(music.sample_rate))
40
print("{0} channels".format(music.channel_count))
45
# loop while the music is playing
46
while music.status == sf.Music.PLAYING:
47
# leave some CPU time for other processes
48
sf.sleep(sf.milliseconds(100))
50
if __name__ == "__main__":
54
input("Press enter to exit...")