From 84acb4de8ca9fa0663b9de35df150cc99d49062a Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Sat, 20 Oct 2007 21:23:51 +0000 Subject: Added support to be able to play wav and aiff format --- diff --git a/NEWS b/NEWS index a6ce158..669edc5 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ - +* Added support to be able to play wav and aiff format (erikos) * Set create tab as default (Muriel) * Games tab renamed to Play (Muriel) * New icon and tooltip for reset game button #3965 (Muriel) diff --git a/activity/activity-memorize.svg b/activity/activity-memorize.svg index 528deaa..4eaf312 100644 --- a/activity/activity-memorize.svg +++ b/activity/activity-memorize.svg @@ -4,11 +4,11 @@ ]> - - - + + + - + diff --git a/csound/univorc.csd b/csound/univorc.csd index b646f8f..d34a2de 100644 --- a/csound/univorc.csd +++ b/csound/univorc.csd @@ -8,10 +8,10 @@ ksmps=100 nchnls=2 /************************************************************************** - General Soundfile Player - Used by Memorize Activity + General ogg-vorbis Soundfile Player **************************************************************************/ -instr 108 +instr 100 /* soundfile play control p4 : filename p5 : unique instance ID @@ -27,7 +27,7 @@ S1 strget p4 inst = p5 ich = 1 iln = 10 -ioffset = p8 +ioffset = p7 Slen sprintf "sfplay.%d.flen", p5 ; file length channel chnset iln, Slen @@ -38,12 +38,12 @@ Sgain sprintf "sfplay.%d.gain", inst ; gain channel chnset S1, Sname chnset 1, Splay chnset p6, Sgain -event_i "i",109,0,iln,inst,ich,ioffset +event_i "i",101,0,iln,inst,ich,ioffset turnoff endin -instr 109 +instr 101 /* soundfile player This is the actual soundfile player. It never gets called directly @@ -71,6 +71,77 @@ endif printf_i "sfplay:%d\n", 1, inst endin + +/************************************************************************** + General wav, aiff Soundfile Player +**************************************************************************/ + +instr 102 +/* soundfile play control + p4 : filename + p5 : unique instance ID + p6 : output gain (0-1) + p7 : offset in seconds + + channels: + sfplay..on - instance control channel (1:on 0: off) + sfplay..gain - soundfile play gain (0-1) + sfplay..flen - holds the channel length +*/ +S1 strget p4 +inst = p5 +ich filenchnls S1 +iln filelen S1 +ioffset = p7 + +Slen sprintf "sfplay.%d.flen", p5 ; file length channel +chnset iln, Slen + +if ioffset >= iln then +turnoff +else +iln = iln - ioffset +endif + +Splay sprintf "sfplay.%d.on", inst ; instance control channel +Sname sprintf "sfplay.%d.fname", inst ; filename channel +Sgain sprintf "sfplay.%d.gain", inst ; gain channel +chnset S1, Sname +chnset 1, Splay +chnset p6, Sgain +event_i "i",103,0,iln,inst,ich,ioffset +turnoff +endin + + +instr 103 +/* soundfile player + This is the actual soundfile player. + It never gets called directly +*/ +ich = p5 +inst= p4 +ioffset = p6 +Splay sprintf "sfplay.%d.on", inst ; instance control channel +Sname sprintf "sfplay.%d.fname", inst ; filename channel +Sgain sprintf "sfplay.%d.gain", inst ; gain channel +kon chnget Splay +kg1 chnget Sgain +S1 chnget Sname +if kon == 0 then +printf "sfplay:%d OFF\n", 1, inst +turnoff +endif +if ich = 1 then +a1 diskin2 S1,1,ioffset,1 +a2 = a1 +else +a1,a2 diskin2 S1,1,ioffset,1 +endif + outs a1*kg1, a2*kg1 +endin + + f0 600000 diff --git a/game.py b/game.py index e825a0d..1f0357d 100755 --- a/game.py +++ b/game.py @@ -152,12 +152,12 @@ class MemorizeGame(gobject.GObject): if self.sound == 1: snd = self.model.grid[id].get('snd', None) if snd != None: - if snd.endswith('.wav'): - pass - # code to csound play wav + if len(snd.split('.')) > 1: + if snd.split('.')[1] in ['wav', 'aif', 'aiff']: + self.cs.perform('i 102 0.0 3.0 "%s" 1 0.9 0'%(os.path.join(os.path.dirname(__file__), snd))) else: - self.cs.perform('i 108 0.0 3.0 "%s" 1 0.9 0'%(os.path.join(os.path.dirname(__file__), snd))) - _logger.debug('Audio: play sound=%s'%snd) + self.cs.perform('i 100 0.0 3.0 "%s" 1 0.9 0'%(os.path.join(os.path.dirname(__file__), snd))) + _logger.debug('Audio: play sound=%s'%snd) # First card case if self.last_flipped == -1: -- cgit v0.9.1