File indexing completed on 2024-05-12 16:23:26

0001 /***************************************************************************
0002  *   Copyright (C) 2013 by Linuxstopmotion contributors;                   *
0003  *   see the AUTHORS file for details.                                     *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #ifndef SOUND_H_
0022 #define SOUND_H_
0023 
0024 #include <string>
0025 
0026 class AudioFormat;
0027 class AudioDriver;
0028 class WorkspaceFile;
0029 class ErrorHandler;
0030 
0031 class Sound {
0032     AudioFormat* af;
0033     const char* name;
0034     Sound& operator=(const Sound&) const;
0035     Sound(const Sound&);
0036 public:
0037     Sound();
0038     ~Sound();
0039     /**
0040      * Opens an audio file. See {@ref AudioFormat::setFilename} for
0041      * exceptions that might be thrown.
0042      * @param file The filename to open. Ownership is not passed.
0043      * @todo We need a way of mocking this for testing.
0044      */
0045     void open(WorkspaceFile& file, ErrorHandler& e);
0046     /**
0047      * Sets or resets the (human-readable) name of this sound.
0048      * @param name The new name or NULL for no name. Name passed must have been
0049      * allocated with new[]. Ownership is passed.
0050      * @return The old name or NULL for no name. Ownership is returned.
0051      */
0052     const char* setName(const char* name);
0053     /**
0054      * Sets the (human-readable) name of this sound. May only be used when
0055      * there is no name already set for the sound.
0056      * @param n The name to set.
0057      */
0058     void setName(std::string& n);
0059     const char* getName() const;
0060     const char* getSoundPath() const;
0061     const char* getBasename() const;
0062     void addToDriver(AudioDriver& ad) const;
0063 };
0064 
0065 #endif