2007-01-07 05:44:11 +01:00
|
|
|
// Copyright (c) 2005, 2006, Rodrigo Braz Monteiro
|
|
|
|
// Copyright (c) 2006, 2007, Niels Martin Hansen
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2007-01-07 05:44:11 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
2009-08-13 19:28:12 +02:00
|
|
|
/// @file audio_renderer_spectrum.h
|
|
|
|
/// @see audio_renderer_spectrum.cpp
|
2009-07-29 07:43:02 +02:00
|
|
|
/// @ingroup audio_ui
|
|
|
|
///
|
2009-08-01 03:55:17 +02:00
|
|
|
/// Calculate and render a frequency-power spectrum for PCM audio data.
|
|
|
|
|
2007-01-07 05:44:11 +01:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2007-01-07 05:44:11 +01:00
|
|
|
|
2009-09-11 04:36:34 +02:00
|
|
|
#ifndef AGI_PRE
|
2007-08-31 16:11:35 +02:00
|
|
|
#include <stdint.h>
|
2009-09-11 04:36:34 +02:00
|
|
|
#endif
|
|
|
|
|
2008-03-07 22:00:20 +01:00
|
|
|
#include "audio_provider_manager.h"
|
2007-01-07 05:44:11 +01:00
|
|
|
|
|
|
|
|
2007-06-30 16:40:52 +02:00
|
|
|
// Specified and implemented in cpp file, interface is private to spectrum code
|
|
|
|
class AudioSpectrumCacheManager;
|
2007-01-07 05:44:11 +01:00
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @class AudioSpectrum
|
2009-08-01 03:55:17 +02:00
|
|
|
/// @brief Render frequency-power spectrum graphs for audio data.
|
|
|
|
///
|
|
|
|
/// Renders frequency-power spectrum graphs of PCM audio data using a fast fourier transform
|
|
|
|
/// to derive the data. The frequency-power data are cached to avoid re-computing them
|
|
|
|
/// frequently, and the cache size is limited by a configuration setting.
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
///
|
2009-08-01 03:55:17 +02:00
|
|
|
/// The spectrum image is rendered to a 32 bit RGB bitmap. Power data is scaled linearly
|
|
|
|
/// and not logarithmically, since the rendering is done with limited precision, but
|
|
|
|
/// an amplification factor can be specified to see different ranges.
|
2007-01-07 05:44:11 +01:00
|
|
|
class AudioSpectrum {
|
|
|
|
private:
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
/// Internal cache management for the spectrum
|
2007-06-30 16:40:52 +02:00
|
|
|
AudioSpectrumCacheManager *cache;
|
2007-01-07 05:44:11 +01:00
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
/// Colour table used for regular rendering
|
2007-01-07 05:44:11 +01:00
|
|
|
unsigned char colours_normal[256*3];
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
/// Colour table used for rendering the audio selection
|
2007-01-07 05:44:11 +01:00
|
|
|
unsigned char colours_selected[256*3];
|
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
/// The audio provider to use as source
|
2007-01-07 05:44:11 +01:00
|
|
|
AudioProvider *provider;
|
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
unsigned long line_length; ///< Number of frequency components per line (half of number of samples)
|
|
|
|
unsigned long num_lines; ///< Number of lines needed for the audio
|
|
|
|
unsigned int fft_overlaps; ///< Number of overlaps used in FFT
|
|
|
|
float power_scale; ///< Amplification of displayed power
|
|
|
|
int minband; ///< Smallest frequency band displayed
|
|
|
|
int maxband; ///< Largest frequency band displayed
|
2007-01-07 05:44:11 +01:00
|
|
|
|
|
|
|
public:
|
2009-08-01 03:55:17 +02:00
|
|
|
/// @brief Constructor
|
|
|
|
/// @param _provider Audio provider to render spectrum data for.
|
|
|
|
///
|
|
|
|
/// Reads configuration data for the spectrum display and initialises itself following that.
|
2007-06-24 22:46:52 +02:00
|
|
|
AudioSpectrum(AudioProvider *_provider);
|
2009-08-01 03:55:17 +02:00
|
|
|
/// @brief Destructor
|
2007-01-07 05:44:11 +01:00
|
|
|
~AudioSpectrum();
|
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
/// @brief Render a range of audio spectrum to a bitmap buffer.
|
|
|
|
/// @param range_start First audio sample in the range to render.
|
|
|
|
/// @param range_end Last audio sample in the range to render.
|
|
|
|
/// @param selected Use the alternate colour palette?
|
|
|
|
/// @param img Pointer to 32 bit RGBX data
|
|
|
|
/// @param imgleft Offset from left edge of bitmap to render to, in pixels
|
|
|
|
/// @param imgwidth Width of bitmap to render, in pixels
|
|
|
|
/// @param imgpitch Offset from one scanline to the next in the bitmap, in bytes
|
|
|
|
/// @param imgheight Number of lines in the bitmap
|
2007-08-31 16:11:35 +02:00
|
|
|
void RenderRange(int64_t range_start, int64_t range_end, bool selected, unsigned char *img, int imgleft, int imgwidth, int imgpitch, int imgheight);
|
2007-01-07 05:44:11 +01:00
|
|
|
|
2009-08-01 03:55:17 +02:00
|
|
|
/// @brief Set the amplification to use when rendering.
|
|
|
|
/// @param _power_scale Amplification factor to use.
|
2007-01-07 05:44:11 +01:00
|
|
|
void SetScaling(float _power_scale);
|
|
|
|
};
|