Package timeside :: Package encoder :: Module wav
[hide private]
[frames] | no frames]

Source Code for Module timeside.encoder.wav

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (c) 2007-2010 Parisson 
 4  # Copyright (c) 2010 Paul Brossier <piem@piem.org> 
 5  # 
 6  # This file is part of TimeSide. 
 7   
 8  # TimeSide is free software: you can redistribute it and/or modify 
 9  # it under the terms of the GNU General Public License as published by 
10  # the Free Software Foundation, either version 2 of the License, or 
11  # (at your option) any later version. 
12   
13  # TimeSide is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU General Public License for more details. 
17   
18  # You should have received a copy of the GNU General Public License 
19  # along with TimeSide.  If not, see <http://www.gnu.org/licenses/>. 
20   
21  # Author: Paul Brossier <piem@piem.org> 
22   
23  from timeside.core import Processor, implements, interfacedoc 
24  from timeside.encoder.core import GstEncoder 
25  from timeside.api import IEncoder 
26  from timeside.tools import * 
27 28 29 -class WavEncoder(GstEncoder):
30 """ gstreamer-based encoder """ 31 implements(IEncoder) 32 33 @interfacedoc
34 - def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
35 super(WavEncoder, self).setup(channels, samplerate, blocksize, totalframes) 36 37 self.pipe = ''' appsrc name=src 38 ! audioconvert 39 ! wavenc 40 ''' 41 if self.filename and self.streaming: 42 self.pipe += ''' ! tee name=t 43 ! queue ! filesink location=%s 44 t. ! queue ! appsink name=app sync=False 45 ''' % self.filename 46 47 elif self.filename : 48 self.pipe += '! filesink location=%s async=False sync=False ' % self.filename 49 else: 50 self.pipe += '! queue ! appsink name=app sync=False ' 51 52 self.start_pipeline(channels, samplerate)
53 54 55 @staticmethod 56 @interfacedoc
57 - def id():
58 return "gst_wav_enc"
59 60 @staticmethod 61 @interfacedoc
62 - def description():
63 return "Wav GStreamer based encoder"
64 65 @staticmethod 66 @interfacedoc
67 - def format():
68 return "WAV"
69 70 @staticmethod 71 @interfacedoc
72 - def file_extension():
73 return "wav"
74 75 @staticmethod 76 @interfacedoc
77 - def mime_type():
78 return "audio/x-wav"
79 80 @interfacedoc
81 - def set_metadata(self, metadata):
82 #TODO 83 pass
84