sfdump.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (c) 1983-2013 Trevor Wishart and Composers Desktop Project Ltd
  3. * http://www.trevorwishart.co.uk
  4. * http://www.composersdesktop.com
  5. *
  6. This file is part of the CDP System.
  7. The CDP System is free software; you can redistribute it
  8. and/or modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2.1 of the License, or (at your option) any later version.
  11. The CDP System is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with the CDP System; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18. 02111-1307 USA
  19. *
  20. */
  21. #define SFD_BLEEP (0)
  22. #define SFD_HEADERS (1)
  23. #define SFD_SOUND (2)
  24. #define SFD_SHORT (3)
  25. #define DUMPFILE_CHANNELS (2)
  26. #define DUMPFILE_SRATE (48000)
  27. #define SFD_CYCLECNT (512) /* number of square wave cycles in bleep */
  28. #define SFD_HALFCYCLE (50) /* square-wave is 50 * 2 samples long */
  29. /* at 44100,stereo = 882 Hz for .58 secs */
  30. #define SFD_SQUAREAMP (8000) /* amplitude of square-wave bleep */
  31. #define SFD_HEADSIZE (SECSIZE * 2) /* bytesize of sndfile header in dumpfile*/
  32. #define SFD_HALFHEADSIZE (SECSIZE) /* half size of sndfile header, in bytes */
  33. #define SFD_HEADCOPIES (100) /* number of bakup copies of header */
  34. #define SFD_DUMPDATSIZE ((SFD_CYCLECNT*SFD_HALFCYCLE*2*sizeof(short))+(SFD_HEADSIZE*SFD_HEADCOPIES))
  35. #define TW_MAGIC (271828182) /* e */
  36. #define FIRST_HALF_SF_MAGIC (30244)
  37. #define SECOND_HALF_SF_MAGIC (5522)
  38. #define FIRST_HALF_TW_MAGIC (-15146)
  39. #define SECOND_HALF_TW_MAGIC (4147)
  40. #define SFD_HEADSEARCHSIZE ((HEADSIZE*HEADCOPIES)+SECSIZE)
  41. #define SFD_COPY_HEADER_WRITTEN (0)
  42. #define SFD_HEADER_SIZE_DEFINED (0)
  43. #define SFD_NAMESIZE (64)
  44. #define BUFFER_START (0)
  45. #define BUFFER_END (1)
  46. #define SFD_INBUF (2)
  47. #define SFD_DATAPTR (0)
  48. #define SFD_DATAEND (1)
  49. #define SFD_OUTBUF (2)
  50. #define SFD_OUTBUFEND (3)
  51. extern char *headend, *hdataend;
  52. extern int sfd_outfilesize;
  53. extern int magicsize;
  54. extern int crcsize;
  55. extern int sizesize;
  56. extern char sfd_outfilename[];
  57. extern int short_secsize;
  58. /* SFREC1.C MAIN */
  59. int read_bytes_aa(char *bbuf,int bytes_to_read,dataptr dz);
  60. int write_bytes_recover
  61. (char *bbuf,int bytes_to_write,int total_bytes_left,int *bytes_written,dataptr dz);
  62. void um(char *,char *,int,int,dataptr dz);
  63. /* SFREC2.C WRITE SOUND */
  64. int relocate_search_position(int *bufpos,int *buffer_full,short *snd_data_end,dataptr dz);
  65. int align_sound_to_buffer(int *buffer_full,int *bufpos,int cnt,int *total_bytes_left,dataptr dz);
  66. int fill_rest_of_buf(int refill_sects,int *buffer_full,dataptr dz);
  67. int adjust_alignment(int bufpos,int buffer_full,short **bptr,dataptr dz);
  68. /* SFREC3.C WRITE SOUND */
  69. int write_snd_rec(int sfd_outfilesize,int *buffer_full,int *total_bytes_left,short **snd_data_end,dataptr dz);
  70. /* SFREC4.C LOCATE HEADER */
  71. int locate_header(int *bufpos,headptr *head_variant,int *buffer_full,int *total_bytes_left,dataptr dz);
  72. int get_true_header(headptr *head_variant,char *headstore,int *sfd_outfilesize,char *sfd_outfilename,dataptr dz);
  73. /* SFREC5.C VERIFY HEADER */
  74. int recover_header(char *headstore,int *sfd_outfilesize,char *sfd_outfilename,dataptr dz);
  75. /************************************************************************
  76. ************************ BUFFER MANIPULATION ***************************
  77. ************************************************************************
  78. *
  79. * STAGGERED BUFFERING
  80. * -------------------
  81. *
  82. * ____________extended_buffer_size_______________
  83. * | |
  84. * | |
  85. * | ..............buffer_size...............|
  86. * | : :
  87. * | : INPUT BUFFER :
  88. * |_______|_______|_______|_______|_______|_______|
  89. * | | | | | O = outbuf
  90. * O I OE I = inbuf
  91. * | OUTPUT BUFFER | OE = outbufend
  92. * | |
  93. * |_______|_______buffer_size_____|_______|remnant
  94. * : : : :
  95. * :....: :....:
  96. * ^ |
  97. * | V
  98. * |___move remnant to start of outbuf____|
  99. *
  100. */