header.py
 1  # SPDX-FileCopyrightText: 2018 Dave Astels for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """
 6  NeoTrellis M4 Express MIDI synth
 7  
 8  Adafruit invests time and resources providing this open source code.
 9  Please support Adafruit and open source hardware by purchasing
10  products from Adafruit!
11  
12  Written by Dave Astels for Adafruit Industries
13  Copyright (c) 2018 Adafruit Industries
14  Licensed under the MIT license.
15  
16  All text above must be included in any redistribution.
17  """
18  
19  class MidiHeader(object):
20  
21      def __init__(self,
22                   midi_format,
23                   number_of_tracks,
24                   ticks_per_frame,
25                   negative_SMPTE_format,
26                   ticks_per_quarternote):
27          self._format = midi_format
28          self._number_of_tracks = number_of_tracks
29          self._ticks_per_frame = ticks_per_frame
30          self._negative_SMPTE_format = negative_SMPTE_format
31          self._ticks_per_quarternote = ticks_per_quarternote
32  
33      @property
34      def number_of_tracks(self):
35          return self._number_of_tracks
36  
37      def __str__(self):
38          format_string = ('Header - format: {0}, '
39                           'track count: {1}, '
40                           'ticks per frame: {2}, '
41                           'SMPTE: {3}, '
42                           'ticks per quarternote: {4}')
43          return format_string.format(self._format,
44                                      self._number_of_tracks,
45                                      self._ticks_per_frame,
46                                      self._negative_SMPTE_format,
47                                      self._ticks_per_quarternote)