Spectrogram

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (Examples: typo)
(update to r5)
Line 2: Line 2:
 
{{Filter3
 
{{Filter3
 
| [http://github.com/innocenat innocenat]
 
| [http://github.com/innocenat innocenat]
| r4
+
| r5
| 3=[http://www.dropbox.com/s/ivh3o1wglw7un0g/Spectrogram.7z?dl=1 Spectrogram.7z]
+
| 3=[http://www.dropbox.com/s/9p2t1mv5t5yjpgd/Spectrogram_r5.7z?dl=1 Spectrogram_r5.7z]
 
| 4=Audio filters
 
| 4=Audio filters
| 5=?
+
| 5=
 
| 6=}}
 
| 6=}}
 
<br>
 
<br>
Line 16: Line 16:
 
* Supported color formats: all colorspaces are supported but output clip will always be [[Y8]].
 
* Supported color formats: all colorspaces are supported but output clip will always be [[Y8]].
 
<br>
 
<br>
 +
* [http://www.microsoft.com/en-us/download/details.aspx?id=40784 Microsoft Visual C++ 2013 Redistributable Package (<tt>vcredist_x86.exe</tt>)]
 +
 
* [http://www.fftw.org/install/windows.html FFTW 3.3.4 <tt>(fftw-3.3.4-dll32.zip)</tt>]
 
* [http://www.fftw.org/install/windows.html FFTW 3.3.4 <tt>(fftw-3.3.4-dll32.zip)</tt>]
 
:<span style="color:red">***</span> 32-bit <tt>libfftw3f-3.dll</tt> needs to be in the search path (<tt>C:\Windows\SysWOW64</tt> 64-bit OS or <tt>C:\windows\system32</tt> 32-bit OS)
 
:<span style="color:red">***</span> 32-bit <tt>libfftw3f-3.dll</tt> needs to be in the search path (<tt>C:\Windows\SysWOW64</tt> 64-bit OS or <tt>C:\windows\system32</tt> 32-bit OS)
Line 23: Line 25:
 
== [[Script variables|Syntax and Parameters]] ==
 
== [[Script variables|Syntax and Parameters]] ==
  
:{{Template:FuncDef|Spectrogram (clip, int, int)}}
+
:{{Template:FuncDef|Spectrogram (clip, int width, int height, bool "transpose")}}
 
<br>
 
<br>
 
::{{Par2| |clip| }}
 
::{{Par2| |clip| }}
:::Input clip; audio must be float so use [[ConvertAudio|ConvertAudioToFloat()]] if needed. If the input clip contains both audio and video, video will be discarded.  
+
:::Input clip; audio must be float so use [[ConvertAudio|ConvertAudioToFloat()]] if needed. Video can be any colorspace but the output will always be [[Y8]].
 +
:::Frame rate of the spectrogram will always default to the frame rate of the input clip. If the input clip does not contain video then the frame rate will default to 24FPS.
 
<br>
 
<br>
 
::{{Par2| |int| }}
 
::{{Par2| |int| }}
Line 34: Line 37:
 
:::Height of the spectrogram. For best performance it's recommended that the height is a value of [http://en.wikipedia.org/wiki/Power_of_two 2^n].
 
:::Height of the spectrogram. For best performance it's recommended that the height is a value of [http://en.wikipedia.org/wiki/Power_of_two 2^n].
 
<br>
 
<br>
::*'''Note:''' all parameters are unnamed and do not have a default so they must be specified.
+
::{{Par2|transpose|bool|false}}
 +
:::When set to true the spectrogram will be rendered vertically; recommended for larger dimensions.
 +
:::<code>Spectrogram(x, y, transpose=true).[[TurnLeft|TurnLeft()]]</code> is identical to <code>Spectrogram(x, y, transpose=false)</code> but faster. For better performance use the optimized <code>FTurnLeft()</code> function from the [[FTurn]] plugin.
 +
<br>
 +
::*'''Note:''' the first 3 parameters are unnamed and do not have a default so they must be specified.
 
<br>
 
<br>
 
== Examples ==
 
== Examples ==
The following script creates a  video from just an audio file. The video length is automatically adjusted based on the duration of the audio and the desired frame rate. The output clip will be Y8, 512x256, and 59.94 FPS, of course this is all adjustable.
+
The following script creates a  scrolling spectrogram from just an audio file. The length is automatically adjusted based on the duration of the audio and the desired frame rate. The output clip will be Y8, 512x256, and 59.94 FPS, of course this is all adjustable.
 
  [[WavSource]]("sample.wav") # for other types of files you can use [[FFmpegSource|FFAudioSource]] or [[LSMASHSource|LWLibavAudioSource]] or any other suitable audio source filter
 
  [[WavSource]]("sample.wav") # for other types of files you can use [[FFmpegSource|FFAudioSource]] or [[LSMASHSource|LWLibavAudioSource]] or any other suitable audio source filter
 
  audio = last<br>
 
  audio = last<br>
Line 46: Line 53:
 
  [[AudioDub]](last, audio)
 
  [[AudioDub]](last, audio)
 
  [[ConvertAudio|ConvertAudioToFloat()]] # if needed<br>
 
  [[ConvertAudio|ConvertAudioToFloat()]] # if needed<br>
  Spectrogram(512,256)<br>
+
  Spectrogram(512, 256, transpose=true)
 +
TurnLeft()<br>
 
  [[File:Spectrogram.png]]
 
  [[File:Spectrogram.png]]
 
<br>
 
<br>
Line 52: Line 60:
 
== Changelog ==
 
== Changelog ==
 
  Version      Date            Changes<br>
 
  Version      Date            Changes<br>
  r4          2015/03/11      - fix a bug; the cache was actually completely broken
+
r5          2015/07/04      - increase cache sizes to accommodate larger dimensions
 +
                              - add "transpose" parameter for better performance<br>
 +
  r4          2015/03/11      - fix a bug; the cache was actually completely broken<br>
 
  r3          2015/03/10      - fix a bug that caused a crash
 
  r3          2015/03/10      - fix a bug that caused a crash
                               - it's now ~40-50% faster; more profiling and fixing a hot spot  
+
                               - it's now ~40-50% faster; more profiling and fixing a hot spot<br>
  r2          2015/03/09      - implement cache; increase speed by profiling  
+
  r2          2015/03/09      - implement cache; increase speed by profiling<br>
 
  r1          2015/03/08      - initial release
 
  r1          2015/03/08      - initial release
<!--<br>
+
<br>
 
== Archived Downloads ==
 
== Archived Downloads ==
{| class="wikitable" border="1"; width="600px"
+
Source code is included.
 +
{| class="wikitable" border="1"; width="500px"
 
|-
 
|-
 
!!width="100px"| Version
 
!!width="100px"| Version
!!width="150px"| Download
+
!!width="200px"| Download
!!width="150px"| Mirror
+
!!width="200px"| Mirror
 
|-
 
|-
!v0.3
+
!r5
|[]
+
|[http://www.dropbox.com/s/9p2t1mv5t5yjpgd/Spectrogram_r5.7z?dl=1 Spectrogram_r5.7z]
|[]
+
|
 
|-
 
|-
!v0.2
+
!r4
|[]
+
|[http://www.dropbox.com/s/ivh3o1wglw7un0g/Spectrogram.7z?dl=1 Spectrogram.7z]
|[]
+
|  
 
|}
 
|}
<br>
 
==External Links ==-->
 
 
<br>
 
<br>
 
<br>
 
<br>
 
-----------------------------------------------
 
-----------------------------------------------
 
'''Back to [[External_filters#Audio_Filters|External Filters]] &larr;'''
 
'''Back to [[External_filters#Audio_Filters|External Filters]] &larr;'''

Revision as of 17:52, 27 July 2015

Abstract
Author innocenat
Version r5
Download Spectrogram_r5.7z
Category Audio filters
License
Discussion


Contents

Description

Linear spectrogram for AviSynth 2.6.

Requirements

  • AviSynth 2.6.0 or greater
  • Supported color formats: all colorspaces are supported but output clip will always be Y8.


*** 32-bit libfftw3f-3.dll needs to be in the search path (C:\Windows\SysWOW64 64-bit OS or C:\windows\system32 32-bit OS)
*** Spectrogram will not run or load without it.


Syntax and Parameters

Spectrogram (clip, int width, int height, bool "transpose")


clip   =
Input clip; audio must be float so use ConvertAudioToFloat() if needed. Video can be any colorspace but the output will always be Y8.
Frame rate of the spectrogram will always default to the frame rate of the input clip. If the input clip does not contain video then the frame rate will default to 24FPS.


int   =
Width of the spectrogram.


int   =
Height of the spectrogram. For best performance it's recommended that the height is a value of 2^n.


bool  transpose = false
When set to true the spectrogram will be rendered vertically; recommended for larger dimensions.
Spectrogram(x, y, transpose=true).TurnLeft() is identical to Spectrogram(x, y, transpose=false) but faster. For better performance use the optimized FTurnLeft() function from the FTurn plugin.


  • Note: the first 3 parameters are unnamed and do not have a default so they must be specified.


Examples

The following script creates a scrolling spectrogram from just an audio file. The length is automatically adjusted based on the duration of the audio and the desired frame rate. The output clip will be Y8, 512x256, and 59.94 FPS, of course this is all adjustable.

WavSource("sample.wav") # for other types of files you can use FFAudioSource or LWLibavAudioSource or any other suitable audio source filter
audio = last
fps = 60000 den = 1001 length = Round((AudioDuration(audio)*fps)/den) BlankClip(length, width=512, height=256, fps=fps, fps_denominator=den, pixel_type="Y8") AudioDub(last, audio) ConvertAudioToFloat() # if needed
Spectrogram(512, 256, transpose=true) TurnLeft()
Spectrogram.png


Changelog

Version      Date            Changes
r5 2015/07/04 - increase cache sizes to accommodate larger dimensions - add "transpose" parameter for better performance
r4 2015/03/11 - fix a bug; the cache was actually completely broken
r3 2015/03/10 - fix a bug that caused a crash - it's now ~40-50% faster; more profiling and fixing a hot spot
r2 2015/03/09 - implement cache; increase speed by profiling
r1 2015/03/08 - initial release


Archived Downloads

Source code is included.

Version Download Mirror
r5 Spectrogram_r5.7z
r4 Spectrogram.7z




Back to External Filters

Personal tools