コード例 #1
0
 def init(self, args):
     Intercom_minimal.init(self, args)
     self.chunks_to_buffer = args.chunks_to_buffer
     self.cells_in_buffer = self.chunks_to_buffer * 2
     #self._buffer = [self.generate_zero_chunk()] * self.cells_in_buffer
     self.packet_format = f"hh{self.samples_per_chunk}h"
     self.sample_type = np.int16
     if __debug__:
         print(f"intercom_buffer: chunks_to_buffer={self.chunks_to_buffer}")
     print("intercom_buffer: buffering")
     chunk_number = 0
     self.empty_chunk = self.generate_zero_chunk()
     print("type=", type(self.empty_chunk[0, 0]))
     self.chunk = np.concatenate(([[0,
                                    0]], self.empty_chunk)).astype(np.int16)
     print("type=", type(self.chunk[0, 0]))
コード例 #2
0
 def add_args(self):
     parser = Intercom_minimal.add_args(self)
     parser.add_argument("-b",
                         "--buffering_time",
                         help="Buffering time in ms.",
                         type=int,
                         default=Intercom_buffer.BUFFERING_TIME)
     return parser
コード例 #3
0
ファイル: intercom_buffer.py プロジェクト: rborgese/intercom
 def add_args(self):
     parser = Intercom_minimal.add_args(self)
     parser.add_argument("-b",
                         "--chunks_to_buffer",
                         help="Number of chunks to buffer",
                         type=int,
                         default=Intercom_buffer.CHUNKS_TO_BUFFER)
     return parser
コード例 #4
0
ファイル: intercom_buffer.py プロジェクト: smvg/intercom
    def init(self, args):
        Intercom_minimal.init(self, args)
        self.chunks_to_buffer = int(math.ceil(args.buffering_time /self.chunk_time))
        print(f"Intercom_Buffer: BUFFERING_TIME={args.buffering_time}")
        #print(args.buffering_time)
        #print(self.chunk_time)
        print(f"Intercom_buffer: chunks_to_buffer={self.chunks_to_buffer}")
        
        # By definition, the buffer has CHUNKS_TO_BUFFER chunks when
        # it is full (and logically, the buffer is empty if there is
        # no chunks inside). However, in order to accommodate large
        # jitters, the buffer is implemented as an sliding window of
        # size CHUNKS_TO_BUFFER that moves ciclically over
        # CHUNKS_TO_BUFFER*2 cells. Thus, in an ideal situation (if
        # all the chunks have been received in order), half of the
        # cells of the complete structure will contain chunks that has
        # been received but that has not been played, and the other
        # half will contain empty chunks (the chunks are zeroed after
        # they has been played). Notice that the buffering time is the
        # time that is needed for fill in half of the buffer (not
        # necessarily starting at cell 0).
        self.cells_in_buffer = self.chunks_to_buffer * 2
        print(f"Intercom_buffer: cells_in_buffer={self.cells_in_buffer}")

        # Now, a chunk is an structure with audio and a chunk
        # counter:
        #
        #  chunk {
        #    int16 chunk_number, unused;
        #    int16 [frames_per_chunk][number_of_channels] sample;
        #  }
        #
        # self.chunk is used for giving format to the incomming
        # chunks.
        #self.chunk_buffer = np.concatenate(([[0, 0]], self.generate_zero_chunk())).astype(np.int16)
        
        chunk_number = 0

        # Initially, all the cells of the buffer will point to this
        # empty chunk.
        self.empty_chunk = self.generate_zero_chunk()

        # Running the user pacifier.
        p = Process(target=self.feedback)
        p.start()
コード例 #5
0
    def init(self, args):
        Intercom_minimal.init(self, args)
        #Los chunks del Buffer se tienen como la cantidad de chunks que se pueden rellenar
        #en el tiempo de buffer.
        self.chunks_to_buffer = int(args.buffering_time / self.chunk_time)
        print(args.buffering_time, self.chunk_time)
        print(f"Intercom_buffer: chunks_to_buffer={self.chunks_to_buffer}")

        #El Buffer tiene el doble de celdas que de chunks para mantener un
        #buffer ideal
        self.cells_in_buffer = self.chunks_to_buffer * 2
        print(f"Intercom_buffer: cells_in_buffer={self.cells_in_buffer}")
        # Initially, all the cells of the buffer will point to this
        # empty chunk.
        self.empty_chunk = self.generate_zero_chunk()

        # Running the user pacifier.
        p = Process(target=self.feedback)
        p.start()
コード例 #6
0
 def receive(self):
     message = Intercom_minimal.receive(self)
     self.received_messages_counter.value += 1
     self.received_bytes_counter.value += len(message)
     return message
コード例 #7
0
 def send_message(self, message):
     Intercom_minimal.send(self, message)
     self.sent_messages_counter.value += 1
     self.sent_bytes_counter.value += len(message)