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.

99 lines
2.8KB

  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. /* FIXME: need locking for when disk thread and peak reader are
  19. * interested in the same source? */
  20. #include "Audio_File.H"
  21. #include "Audio_File_SF.H"
  22. std::map <std::string, Audio_File*> Audio_File::_open_files;
  23. Audio_File::~Audio_File ( )
  24. {
  25. _open_files[ std::string( _filename ) ] = NULL;
  26. }
  27. void
  28. Audio_File::all_supported_formats ( std::list <const char *> &formats )
  29. {
  30. const format_desc *fd;
  31. fd = Audio_File_SF::supported_formats;
  32. for ( ; fd->name; ++fd )
  33. formats.push_back( fd->name );
  34. }
  35. /** attmpet to open any supported filetype */
  36. Audio_File *
  37. Audio_File::from_file ( const char * filename )
  38. {
  39. Audio_File *a;
  40. if ( ( a = _open_files[ std::string( filename ) ] ) )
  41. return a;
  42. if ( ( a = Audio_File_SF::from_file( filename ) ) )
  43. goto done;
  44. // TODO: other formats
  45. return NULL;
  46. done:
  47. /* a->_peaks = new Peaks; */
  48. /* a->_peaks->clip( a ); */
  49. /* a->_peaks->open(); */
  50. _open_files[ std::string( filename ) ] = a;
  51. return a;
  52. }
  53. bool
  54. Audio_File::read_peaks( float fpp, nframes_t start, nframes_t end, int *peaks, Peak **pbuf, int *channels )
  55. {
  56. // Peaks pk;
  57. *peaks = 0;
  58. *channels = 0;
  59. *pbuf = NULL;
  60. // pk.clip( this );
  61. /* /\* only open peaks (and potentially generate) when first requested *\/ */
  62. /* if ( ! _peaks.open() ) */
  63. /* return false; */
  64. *peaks = _peaks.fill_buffer( fpp, start, end );
  65. *channels = this->channels();
  66. *pbuf = _peaks.peakbuf();
  67. return true;
  68. }