Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.9KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma once
  19. #include "grid.H"
  20. class pattern;
  21. class phrase;
  22. #include <stdio.h>
  23. class smf
  24. {
  25. char * _name;
  26. int _format; /* 0, 1, 2 */
  27. FILE *_fp;
  28. /* reader */
  29. long _length; /* length of the current chunk */
  30. long _pos; /* number of bytes read from chunk */
  31. int _ppqn; /* PPQN of imported files */
  32. /* writer */
  33. unsigned int _tally; /* number of bytes written thus far */
  34. long _num_tracks_pos; /* where to write the number of tracks when known */
  35. long _length_pos; /* where to write the chunk length when known */
  36. int _cue; /* transform note ons to cue events for this track */
  37. int _tracks; /* number of tracks */
  38. int _track; /* current track */
  39. tick_t _time; /* current timestamp in writer */
  40. int _mode;
  41. byte_t _status;
  42. public:
  43. enum { WRITE, READ };
  44. unsigned long read_long ( void );
  45. unsigned short read_short ( void );
  46. unsigned long read_var ( void );
  47. void read_bytes ( void *p, int l );
  48. byte_t read_byte ( void );
  49. void write_var ( long var );
  50. void write_long ( unsigned long x );
  51. void write_ascii ( const char *buf );
  52. void write_short ( unsigned short x );
  53. void write_byte ( byte_t b );
  54. void write_bytes ( const void *p, size_t l );
  55. /* Meta Event codes */
  56. enum {
  57. SEQUENCE = 0x00,
  58. TEXT = 0x01,
  59. COPYRIGHT = 0x02,
  60. NAME = 0x03,
  61. INSTRUMENT = 0x04,
  62. LYRIC = 0x05,
  63. MARKER = 0x06,
  64. CUEPOINT = 0x07,
  65. PROGRAM = 0x08,
  66. DEVICE = 0x09,
  67. CHANNEL = 0x20,
  68. PORT = 0x21,
  69. END = 0x2F,
  70. TEMPO = 0x51,
  71. SMPTE = 0x54,
  72. TIMESIG = 0x58,
  73. KEYSIG = 0x59,
  74. PROPRIETARY = 0x7F
  75. };
  76. smf( void );
  77. ~smf( void );
  78. int open ( const char *name, int mode );
  79. static void print_track_listing ( const char *name );
  80. void write_meta_event ( byte_t type, int n );
  81. void write_meta_event ( byte_t type, const char *s );
  82. void write_event ( const MIDI::midievent *e );
  83. void write_header ( int tracks );
  84. void open_chunk ( const char *id );
  85. void close_chunk ( void );
  86. void open_track ( const char *name, int num );
  87. void close_track ( tick_t length );
  88. void write_pattern_info ( const pattern *p );
  89. void cue ( bool b );
  90. list <MIDI::midievent> * read_track_events ( tick_t *length );
  91. void write_phrase_info ( const phrase *p );
  92. bool read_song_info( int *mode, int *phrases, int *patterns, char **name, char **notes );
  93. void write_song_info( int mode, int phrases, int patterns, const char *name, const char *notes );
  94. void home ( void );
  95. void skip ( size_t l );
  96. void backup ( size_t l );
  97. int next_track ( void );
  98. bool seek_track ( int n );
  99. char ** track_listing ( void );
  100. char * read_cue_point ( void );
  101. int read_header ( void );
  102. char * read_text ( void );
  103. char * read_track_name ( void );
  104. bool read_phrase_info ( phrase *p );
  105. bool read_pattern_info ( pattern *p );
  106. int format ( void ) const;
  107. int tracks ( void ) const;
  108. };