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.

145 lines
5.0KB

  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. #include "event.H"
  21. class pattern;
  22. class phrase;
  23. #include <stdio.h>
  24. class smf
  25. {
  26. char * _name;
  27. int _format; /* 0, 1, 2 */
  28. FILE *_fp;
  29. /* reader */
  30. long _length; /* length of the current chunk */
  31. long _pos; /* number of bytes read from chunk */
  32. int _ppqn; /* PPQN of imported files */
  33. /* writer */
  34. unsigned int _tally; /* number of bytes written thus far */
  35. long _num_tracks_pos; /* where to write the number of tracks when known */
  36. long _length_pos; /* where to write the chunk length when known */
  37. int _cue; /* transform note ons to cue events for this track */
  38. int _tracks; /* number of tracks */
  39. int _track; /* current track */
  40. tick_t _time; /* current timestamp in writer */
  41. int _mode;
  42. byte_t _status;
  43. public:
  44. enum { WRITE, READ };
  45. unsigned long read_long ( void );
  46. unsigned short read_short ( void );
  47. unsigned long read_var ( void );
  48. void read_bytes ( void *p, int l );
  49. byte_t read_byte ( void );
  50. void write_var ( long var );
  51. void write_long ( unsigned long x );
  52. void write_ascii ( const char *buf );
  53. void write_short ( unsigned short x );
  54. void write_byte ( byte_t b );
  55. void write_bytes ( const void *p, size_t l );
  56. /* Meta Event codes */
  57. enum {
  58. SEQUENCE = 0x00,
  59. TEXT = 0x01,
  60. COPYRIGHT = 0x02,
  61. NAME = 0x03,
  62. INSTRUMENT = 0x04,
  63. LYRIC = 0x05,
  64. MARKER = 0x06,
  65. CUEPOINT = 0x07,
  66. PROGRAM = 0x08,
  67. DEVICE = 0x09,
  68. CHANNEL = 0x20,
  69. PORT = 0x21,
  70. END = 0x2F,
  71. TEMPO = 0x51,
  72. SMPTE = 0x54,
  73. TIMESIG = 0x58,
  74. KEYSIG = 0x59,
  75. PROPRIETARY = 0x7F
  76. };
  77. smf( void );
  78. ~smf( void );
  79. int open ( const char *name, int mode );
  80. static void print_track_listing ( const char *name );
  81. void write_meta_event ( byte_t type, int n );
  82. void write_meta_event ( byte_t type, const char *s );
  83. void write_event ( const midievent *e );
  84. void write_header ( int tracks );
  85. void open_chunk ( const char *id );
  86. void close_chunk ( void );
  87. void open_track ( const char *name, int num );
  88. void close_track ( tick_t length );
  89. void write_pattern_info ( const pattern *p );
  90. void cue ( bool b );
  91. list <midievent> * read_track_events ( tick_t *length );
  92. void write_phrase_info ( const phrase *p );
  93. bool read_song_info( int *mode, int *phrases, int *patterns, char **name, char **notes );
  94. void write_song_info( int mode, int phrases, int patterns, const char *name, const char *notes );
  95. void home ( void );
  96. void skip ( size_t l );
  97. void backup ( size_t l );
  98. int next_track ( void );
  99. bool seek_track ( int n );
  100. char ** track_listing ( void );
  101. char * read_cue_point ( void );
  102. int read_header ( void );
  103. char * read_text ( void );
  104. char * read_track_name ( void );
  105. bool read_phrase_info ( phrase *p );
  106. bool read_pattern_info ( pattern *p );
  107. int format ( void ) const;
  108. int tracks ( void ) const;
  109. };