changeset 70:8cfe5e7dc91e

Mark AudioSource attributes as read-only properties
author Amine SEHILI <amine.sehili@gmail.com>
date Sun, 05 Feb 2017 11:39:34 +0100
parents d52581cfc9b6
children 56ede0db2d19
files auditok/io.py
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/io.py	Sat Jan 28 13:03:37 2017 +0100
+++ b/auditok/io.py	Sun Feb 05 11:39:34 2017 +0100
@@ -69,9 +69,9 @@
         if channels != 1:
             raise ValueError("Only mono audio is currently handled")
 
-        self.sampling_rate = sampling_rate
-        self.sample_width = sample_width
-        self.channels = channels
+        self._sampling_rate = sampling_rate
+        self._sample_width = sample_width
+        self._channels = channels
 
     @abstractmethod
     def is_open(self):
@@ -108,14 +108,29 @@
         """ Return the number of samples per second of audio stream """
         return self.sampling_rate
 
+    @property
+    def sampling_rate(self):
+        """ Number of samples per second of audio stream """
+        return self._sampling_rate
+
     def get_sample_width(self):
         """ Return the number of bytes used to represent one audio sample """
         return self.sample_width
 
+    @property
+    def sample_width(self):
+        """ Number of bytes used to represent one audio sample """
+        return self._sample_width
+
     def get_channels(self):
         """ Return the number of channels of this audio source """
         return self.channels
 
+    @property
+    def channels(self):
+        """ Number of channels of this audio source """
+        return self._channels
+
 
 class Rewindable():
     """