Nsound  0.9.4
MixerNode.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: MixerNode.cc 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 // Copyright (c) 2005-2006 Nick Hilton
6 //
7 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
8 //
9 //-----------------------------------------------------------------------------
10 
11 //-----------------------------------------------------------------------------
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2 of the License, or
16 // (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Library General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 //
27 //-----------------------------------------------------------------------------
28 
29 #include <Nsound/AudioStream.h>
30 #include <Nsound/MixerNode.h>
31 
32 #include <iostream>
33 #include <sstream>
34 #include <string.h>
35 
36 using namespace Nsound;
37 
39 
41 //
42 // Constructor
43 //
46 MixerNode(float64 time, float64 bpm, const AudioStream & as)
47  : audio_stream_(&as),
48  bpm_(bpm),
49  first_beat_time_(time),
50  id_(MixerNode::id_count_++)
51 {}
52 
53 boolean
55 operator==(const MixerNode & rhs) const
56 {
57  if(id_ == rhs.id_
58  && bpm_ == rhs.bpm_
59  && first_beat_time_ == rhs.first_beat_time_)
60  {
61  return true;
62  }
63 
64  return false;
65 }
66 
67 boolean
69 operator<(const MixerNode & rhs) const
70 {
71  if(first_beat_time_ < rhs.first_beat_time_
72  || id_ < rhs.id_)
73  {
74  return true;
75  }
76 
77  return false;
78 }
79 
81 // print()
82 //
83 // This method returns a string that represents the node.
84 //
86 std::string
89 {
90  using std::endl;
91 
92  std::stringstream out;
93 
94  out << "first_beat_time_: "
95  << first_beat_time_
96  << endl
97  << "bpm_: "
98  << bpm_
99  << endl
100  << "audio_stream_ length: "
101  << static_cast<float64>(audio_stream_->getLength())
102  / static_cast<float64>(audio_stream_->getSampleRate())
103  << " seconds"
104  << endl
105  << endl;
106 
107  return out.str();
108 }
unsigned int uint32
Definition: Nsound.h:153
std::string printNode()
This method returns a string that represents the node.
Definition: MixerNode.cc:88
boolean operator==(const MixerNode &) const
Definition: MixerNode.cc:55
double float64
Definition: Nsound.h:146
static uint32 id_count_
Definition: MixerNode.h:94
boolean operator<(const MixerNode &) const
Definition: MixerNode.cc:69
This class holds the nodes for use with the Mixer class.
Definition: MixerNode.h:55
float64 first_beat_time_
The time the AudioStream first occurs in the list.
Definition: MixerNode.h:90
float64 bpm_
The number of beats per minute.
Definition: MixerNode.h:87
MixerNode(float64 first_beat_time, float64 bpm, const AudioStream &as)
Constructor.
Definition: MixerNode.cc:46