tahoma2d/toonz/sources/include/toonz/txshsoundlevel.h

101 lines
2.4 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TXSHSOUNDLEVEL_INCLUDED
#define TXSHSOUNDLEVEL_INCLUDED
#include "toonz/txshlevel.h"
#include "tsound.h"
#include <QList>
#include "tpersist.h"
#undef DVAPI
#undef DVVAR
#ifdef TOONZLIB_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class DVAPI TXshSoundLevel final : public TXshLevel {
2016-06-15 18:43:10 +12:00
PERSIST_DECLARATION(TXshSoundLevel)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TSoundTrackP m_soundTrack;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
double m_duration; // overall soundtrack duration in seconds
double m_samplePerFrame;
int m_frameSoundCount;
double m_fps;
//! Values is a map of \b Integer and \b DoublePair.
/*!Integer is horizontal value of row pixel.
DoublePair is computed according to frameRate, frameCount
and soundtrack pressure.*/
std::map<int, DoublePair> m_values;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TFilePath m_path;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DECLARE_CLASS_CODE
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TXshSoundLevel(std::wstring name = L"", int startOffset = 0,
int endOffset = 0);
~TXshSoundLevel();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TXshSoundLevel *clone() const;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void setScene(ToonzScene *scene) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Overridden from TXshLevel
2016-06-19 20:06:29 +12:00
TXshSoundLevel *getSoundLevel() override { return this; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void loadSoundTrack();
void loadSoundTrack(const TFilePath &fileName);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void loadData(TIStream &is) override;
void saveData(TOStream &os) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void load() override;
void save() override;
2016-06-15 18:43:10 +12:00
void save(const TFilePath &path);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void computeValues(int frameHeight = 20);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void getValueAtPixel(int pixel, DoublePair &values) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*! Set frame rate to \b fps. \sa getSamplePerFrame() */
void setFrameRate(double fps);
double getFrameRate() const { return m_fps; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setPath(const TFilePath &path) { m_path = path; }
2016-06-19 20:06:29 +12:00
TFilePath getPath() const override { return m_path; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setSoundTrack(TSoundTrackP st) {
m_soundTrack = st;
computeValues();
}
TSoundTrackP getSoundTrack() { return m_soundTrack; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Pay Attention this is the sound frame !!
int getFrameSoundCount() const { return m_frameSoundCount; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getSamplePerFrame() const { return m_samplePerFrame; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getFrameCount() const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void getFids(std::vector<TFrameId> &fids) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
// not implemented
TXshSoundLevel(const TXshSoundLevel &);
TXshSoundLevel &operator=(const TXshSoundLevel &);
2016-03-19 06:57:51 +13:00
};
2016-04-15 17:11:23 +12:00
#ifdef _WIN32
2016-03-19 06:57:51 +13:00
template class DV_EXPORT_API TSmartPointerT<TXshSoundLevel>;
#endif
typedef TSmartPointerT<TXshSoundLevel> TXshSoundLevelP;
2016-06-15 18:43:10 +12:00
#endif // TXSHSOUNDLEVEL_INCLUDED