| 1 |
/* Libvisual-plugins - Standard plugins for libvisual |
| 2 |
* |
| 3 |
* Copyright (C) 2002, 2003, 2004, 2005, 2006 Dennis Smit <[email protected]> |
| 4 |
* |
| 5 |
* Authors: Dennis Smit <[email protected]> |
| 6 |
* |
| 7 |
* $Id: audio.c,v 1.6 2006/01/22 13:25:26 synap Exp $ |
| 8 |
* |
| 9 |
* This program is free software; you can redistribute it and/or modify |
| 10 |
* it under the terms of the GNU General Public License as |
| 11 |
* published by the Free Software Foundation; either version 2 |
| 12 |
* of the License, or (at your option) any later version. |
| 13 |
* |
| 14 |
* This program is distributed in the hope that it will be useful, |
| 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
* GNU General Public License for more details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU General Public License |
| 20 |
* along with this program; if not, write to the Free Software |
| 21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 |
*/ |
| 23 |
|
| 24 |
#include <string.h> |
| 25 |
#include <math.h> |
| 26 |
|
| 27 |
#include "oinksie.h" |
| 28 |
#include "common.h" |
| 29 |
#include "gfx-palette.h" |
| 30 |
#include "config.h" |
| 31 |
#include "audio.h" |
| 32 |
|
| 33 |
|
| 34 |
/* audio priv->audio.freq analyze */ |
| 35 |
void _oink_audio_analyse (OinksiePrivate *priv) |
| 36 |
{ |
| 37 |
int i, j; |
| 38 |
float total, mean; |
| 39 |
|
| 40 |
priv->audio.bass = (priv->audio.freqsmall[0] + priv->audio.freqsmall[1]) * 20; |
| 41 |
priv->audio.tripple = (priv->audio.freqsmall[2] + priv->audio.freqsmall[3]) * 100; |
| 42 |
|
| 43 |
|
| 44 |
priv->audio.highest = MAX (priv->audio.bass, priv->audio.tripple); |
| 45 |
|
| 46 |
if (priv->audio.bass >= 0 && priv->audio.bass <= 2) |
| 47 |
priv->audio.musicmood = 0; |
| 48 |
else if (priv->audio.bass >= 3 && priv->audio.bass <= 6) |
| 49 |
priv->audio.musicmood = 1; |
| 50 |
else if (priv->audio.bass >= 7 && priv->audio.bass <= 10) |
| 51 |
priv->audio.musicmood = 2; |
| 52 |
else |
| 53 |
priv->audio.musicmood = 0; |
| 54 |
|
| 55 |
priv->audio.beat = FALSE; |
| 56 |
|
| 57 |
if (priv->audio.bass >= 9) |
| 58 |
priv->audio.beat = TRUE; |
| 59 |
} |
| 60 |
|