Exemplo n.º 1
0
 def __init__(self,
              peer_address,
              sport=0,
              rport=0,
              latency=20,
              jitter_buffer_size=10,
              safe_keyboard=0,
              recovery=1,
              follow_standard=0,
              verbose=0):
     #Init mother class
     RTPSession.__init__(self, peer_address, sport, rport, PAYLOAD,
                         jitter_buffer_size, TOOL_NAME)
     self.verbose = verbose
     if verbose:
         print("Your configuration:")
         print("  Latency:", latency, "ms")
         print("  Jitter Buffer Time:", jitter_buffer_size, "ms")
     #init midi
     if self.sport > 0:
         self.midi_in = MidiIn(self, verbose)
     #1 == Permisive mode (make this configurable)
     if self.rport > 0:
         self.midi_out = MidiOut(0, latency, safe_keyboard, verbose)
     #history of the feed
     self.packets_received_list = PacketCirc(HISTORY_SIZE)
     #Recovery utils
     self.recovery = 0
     self.recovery_journal_system = None
     if recovery:
         self.recovery = 1
         self.recovery_journal_system = RecoveryJournal(follow_standard)
         if verbose:
             print("  Recovery journal is running")
             if follow_standard:
                 print("  Recovery is following standard")
     self.init_timestamp = None
     #Flag
     self.sending_data = 0
     self.receiving_data = 0
     #Timestamp story
     self.last_midi_time_sent = pypm.Time()
     self.timeouterLoop = None
Exemplo n.º 2
0
 def send_silence(self):
     """
     Sends empty packet to signal a silent period
     """
     recovery_journal = ""
     marker_j = 0
     #Getting recovery
     if self.recovery:
         recovery_journal = self.recovery_journal_system.content
         if recovery_journal != "":
             #Recovery Journal 1 if present
             marker_j = 1
     #Creating empty midicommand filed
     header = MidiCommand().header(0, marker_j, 1, 1, 0)
     if recovery_journal != "":
         chunk = header + recovery_journal
     else:
         chunk = str(0)
     #sending silent packet with recovery journal
     RTPSession.send_empty_packet(self, chunk)
Exemplo n.º 3
0
 def send_silence(self):
     """
     Sends empty packet to signal a silent period
     """
     recovery_journal = ""
     marker_j = 0
     #Getting recovery
     if self.recovery:
         recovery_journal = self.recovery_journal_system.content
         if recovery_journal != "":
             #Recovery Journal 1 if present
             marker_j = 1
     #Creating empty midicommand filed
     header = MidiCommand().header(0, marker_j, 1, 1, 0)
     if recovery_journal != "":
         chunk = header + recovery_journal
     else:
         chunk = str(0)
     #sending silent packet with recovery journal
     RTPSession.send_empty_packet(self, chunk)
Exemplo n.º 4
0
 def send_midi_data(self, data, midi_time, recovery=1, timestamp=1):
     """
     Sends MIDI data through the RTP session.
     """
     if DEBUG:
         print("Sending data", data)
     #Witness
     self.sending_data = 1
     #midi Cmd List
     midi_list = data
     #Saving packet
     packet = OldPacket(self.seq, midi_list, 0)
     chunk = ""
     recovery_journal = ""
     if recovery:
         #Recovery Journal (can be empty)
         #TODO customize it for each member of the feed
         if self.recovery_journal_system is not None:
             recovery_journal = self.recovery_journal_system.content
             if recovery_journal == "":
                 recovery = 0
     #Packing All
     #Testing length of midi list ( in nb notes )
     if len(midi_list) < 1:
         return
     #Formating commands for network
     midi_list_formated, length = \
         MidiCommand().encode_midi_commands(midi_list)
     #Creating Header
     header = MidiCommand().header(0, recovery, 0, 0, length)
     #Building Chunk
     chunk = header + midi_list_formated + recovery_journal
     #Timestamp care (TS == temps midi ecouler depuis la creation de rtp)
     ts = midi_time - self.last_midi_time_sent
     self.last_midi_time_sent = midi_time
     #sending data to rtp session
     RTPSession.send_data(self, chunk, ts)
     self.sending_data = 0
     #Updating Recovery Journal
     if self.recovery:
         self.recovery_journal_system.update(packet)
Exemplo n.º 5
0
 def send_midi_data(self, data, midi_time, recovery=1, timestamp=1):
     """
     Sends MIDI data through the RTP session.
     """
     if DEBUG:
         print "Sending data", data
     #Witness
     self.sending_data = 1
     #midi Cmd List
     midi_list = data
     #Saving packet
     packet = OldPacket(self.seq, midi_list, 0)
     chunk = ""
     recovery_journal = ""
     if recovery:
         #Recovery Journal (can be empty)
         #TODO customize it for each member of the feed
         if self.recovery_journal_system is not None:
             recovery_journal = self.recovery_journal_system.content
             if recovery_journal == "":
                 recovery = 0
     #Packing All
     #Testing length of midi list ( in nb notes )
     if len(midi_list) < 1:
         return
     #Formating commands for network
     midi_list_formated, length = \
         MidiCommand().encode_midi_commands(midi_list)
     #Creating Header
     header = MidiCommand().header(0, recovery, 0, 0, length)
     #Building Chunk
     chunk = header + midi_list_formated + recovery_journal
     #Timestamp care (TS == temps midi ecouler depuis la creation de rtp)
     ts = midi_time - self.last_midi_time_sent
     self.last_midi_time_sent = midi_time
     #sending data to rtp session
     RTPSession.send_data(self, chunk, ts)
     self.sending_data = 0
     #Updating Recovery Journal
     if self.recovery:
         self.recovery_journal_system.update(packet)
Exemplo n.º 6
0
 def __init__(self, peer_address, sport=0, rport=0, latency=20,
              jitter_buffer_size=10, safe_keyboard=0, recovery=1,
              follow_standard=0, verbose=0):
     #Init mother class
     RTPSession.__init__(self, peer_address, sport, rport, PAYLOAD,
                         jitter_buffer_size, TOOL_NAME)
     self.verbose = verbose
     if verbose:
         print "Your configuration:"
         print "  Latency:", latency, "ms"
         print "  Jitter Buffer Time:", jitter_buffer_size, "ms"
     #init midi
     if self.sport > 0:
         self.midi_in = MidiIn(self, verbose)
     #1 == Permisive mode (make this configurable)
     if self.rport > 0:
         self.midi_out = MidiOut(0, latency, safe_keyboard, verbose)
     #history of the feed
     self.packets_received_list = PacketCirc(HISTORY_SIZE)
     #Recovery utils
     self.recovery = 0
     self.recovery_journal_system = None
     if recovery:
         self.recovery = 1
         self.recovery_journal_system = RecoveryJournal(follow_standard)
         if verbose:
             print "  Recovery journal is running"
             if follow_standard:
                 print "  Recovery is following standard"
     self.init_timestamp = None
     #Flag
     self.sending_data = 0
     self.receiving_data = 0
     #Timestamp story
     self.last_midi_time_sent = pypm.Time()
     self.timeouterLoop = None