mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-29 18:14:16 +00:00
Got rid of core/audio/tstl.h.
* Fixed all references in core/audio and ConsoleUI. * Extended config.h in core * Added config.h to square Removed some unnecessary #includes
This commit is contained in:
parent
65bf15f94b
commit
d389e9e9f1
@ -1,12 +1,10 @@
|
||||
#include "pch.hpp"
|
||||
|
||||
#include <core/audio/AudioStream.h>
|
||||
#include <core/audio/IAudioSource.h>
|
||||
#include <core/audio/IAudioOutput.h>
|
||||
#include <core/audio/IAudioSource.h>
|
||||
#include <core/audio/Transport.h>
|
||||
|
||||
#include "tstl.h"
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
||||
unsigned long AudioStream::streamsCreated = 0;
|
||||
@ -144,42 +142,7 @@ bool AudioStream::GetBuffer(float * pAudioBuffer, unsigned long NumSamples)
|
||||
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
unsigned long AudioStream::GetState(void)
|
||||
{
|
||||
return this->playState;
|
||||
}
|
||||
|
||||
unsigned long AudioStream::GetFadeState(void)
|
||||
{
|
||||
return this->fadeState;
|
||||
}
|
||||
|
||||
bool AudioStream::IsFinished(void)
|
||||
{
|
||||
return this->isFinished;
|
||||
}
|
||||
|
||||
bool AudioStream::FadeIn(unsigned long ulMS)
|
||||
{
|
||||
AutoLock t(&this->lock);
|
||||
|
||||
this->fadeState = FadeStateIn;
|
||||
this->volumeChange = 1.0f / ((float)ulMS * (float)this->output->GetSampleRate());
|
||||
this->volume = 0.0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioStream::FadeOut(unsigned long ulMS)
|
||||
{
|
||||
AutoLock t(&this->lock);
|
||||
|
||||
this->fadeState = FadeStateOut;
|
||||
this->volumeChange = -(1.0f / ((float)ulMS * (float)this->output->GetSampleRate()));
|
||||
this->volume = 1.0f;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
bool AudioStream::Start()
|
||||
{
|
||||
if (this->output->Start())
|
||||
@ -249,7 +212,7 @@ bool AudioStream::SetPosition(unsigned long MS)
|
||||
|
||||
utfstring AudioStream::ToString() const
|
||||
{
|
||||
std::tstringstream ss;
|
||||
std::utfstringstream ss;
|
||||
|
||||
ss << this->streamId << " " << this->audioSource->GetSource();
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include <core/audio/IAudioCallBack.h>
|
||||
#include <core/audio/AudioPacketizer.h>
|
||||
#include <core/audio/IAudioCallBack.h>
|
||||
|
||||
namespace musik { namespace core { namespace audio {
|
||||
|
||||
@ -70,16 +70,6 @@ private: bool SetPosition(unsigned long MS);
|
||||
// TODO: decide what to do with this when integrating into mC2
|
||||
int GetCrossfadeTime() {return 0;}; // TuniacApp.Preferences
|
||||
bool GetActivePlaylistCheckNext() { return false; }; //TuniacApp.PLaylistManager
|
||||
|
||||
////////////////////////////:
|
||||
// Old - this isn't used anywhere. Maybe we'll need it again.
|
||||
//private:
|
||||
// unsigned long GetState(void);
|
||||
// unsigned long GetFadeState(void);
|
||||
// bool IsFinished(void);
|
||||
// bool FadeIn(unsigned long ulMS);
|
||||
// bool FadeOut(unsigned long ulMS);
|
||||
// bool GetVisData(float * ToHere, unsigned long ulNumSamples);
|
||||
};
|
||||
|
||||
}}} // NS
|
||||
|
@ -6,7 +6,7 @@ class IAudioCallback
|
||||
{
|
||||
protected: virtual ~IAudioCallback() {};
|
||||
|
||||
public: virtual bool GetBuffer(float * pAudioBuffer, unsigned long NumSamples) = 0;
|
||||
public: virtual bool GetBuffer(float * pAudioBuffer, unsigned long NumSamples) = 0;
|
||||
};
|
||||
|
||||
}}} // NS
|
@ -33,10 +33,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <core/audio/IAudioCallback.h>
|
||||
|
||||
namespace musik { namespace core { namespace audio {
|
||||
|
||||
class IAudioCallback;
|
||||
|
||||
class IAudioOutput
|
||||
{
|
||||
public: virtual void Destroy() = 0;
|
||||
|
@ -33,13 +33,14 @@
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include <core/audio/Transport.h>
|
||||
#include <core/audio/IAudioSource.h>
|
||||
#include <core/audio/IAudioOutput.h>
|
||||
#include <core/audio/AudioStream.h>
|
||||
#include "Transport.h"
|
||||
|
||||
#include <core/PluginFactory.h>
|
||||
|
||||
#include <core/audio/AudioStream.h>
|
||||
#include <core/audio/IAudioOutput.h>
|
||||
#include <core/audio/IAudioSource.h>
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
||||
Transport::Transport() :
|
||||
|
@ -33,15 +33,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <sigslot/sigslot.h>
|
||||
|
||||
#include <core/config.h>
|
||||
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include "sigslot/sigslot.h"
|
||||
|
||||
namespace musik { namespace core { namespace audio {
|
||||
|
||||
class AudioStream;
|
||||
|
@ -1,76 +0,0 @@
|
||||
// tstl.h - header file for TCHAR equivalents of STL
|
||||
// string and stream classes
|
||||
//
|
||||
// Copyright (c) 2006 PJ Arends
|
||||
//
|
||||
// This file is provided "AS-IS". Use and/or abuse it
|
||||
// in any way you feel fit.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
|
||||
namespace std
|
||||
{
|
||||
#if defined UNICODE || defined _UNICODE
|
||||
|
||||
typedef wchar_t tchar;
|
||||
typedef wstring tstring;
|
||||
|
||||
typedef wstringbuf tstringbuf;
|
||||
typedef wstringstream tstringstream;
|
||||
typedef wostringstream tostringstream;
|
||||
typedef wistringstream tistringstream;
|
||||
|
||||
typedef wstreambuf tstreambuf;
|
||||
|
||||
typedef wistream tistream;
|
||||
typedef wiostream tiostream;
|
||||
|
||||
typedef wostream tostream;
|
||||
|
||||
typedef wfilebuf tfilebuf;
|
||||
typedef wfstream tfstream;
|
||||
typedef wifstream tifstream;
|
||||
typedef wofstream tofstream;
|
||||
|
||||
typedef wios tios;
|
||||
|
||||
# define tcerr wcerr
|
||||
# define tcin wcin
|
||||
# define tclog wclog
|
||||
# define tcout wcout
|
||||
|
||||
#else // defined UNICODE || defined _UNICODE
|
||||
|
||||
typedef char tchar;
|
||||
typedef string tstring;
|
||||
|
||||
typedef stringbuf tstringbuf;
|
||||
typedef stringstream tstringstream;
|
||||
typedef ostringstream tostringstream;
|
||||
typedef istringstream tistringstream;
|
||||
|
||||
typedef streambuf tstreambuf;
|
||||
|
||||
typedef istream tistream;
|
||||
typedef iostream tiostream;
|
||||
|
||||
typedef ostream tostream;
|
||||
|
||||
typedef filebuf tfilebuf;
|
||||
typedef fstream tfstream;
|
||||
typedef ifstream tifstream;
|
||||
typedef ofstream tofstream;
|
||||
|
||||
typedef ios tios;
|
||||
|
||||
# define tcerr cerr
|
||||
# define tcin cin
|
||||
# define tclog clog
|
||||
# define tcout cout
|
||||
|
||||
#endif // defined UNICODE || defined _UNICODE
|
||||
} // namespace std
|
@ -100,6 +100,17 @@ typedef unsigned int DBTIME;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///utfstringstream is the stringstream for utfchar & utfstring
|
||||
//////////////////////////////////////////
|
||||
namespace std
|
||||
{
|
||||
typedef wstringstream utfstringstream;
|
||||
typedef wostringstream utfostringstream;
|
||||
typedef wistringstream utfistringstream;
|
||||
}
|
||||
|
||||
#else
|
||||
#undef UTF_WIDECHAR
|
||||
|
||||
@ -126,11 +137,24 @@ typedef unsigned int DBTIME;
|
||||
typedef directory_iterator utfdirectory_iterator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///utfstringstream is the stringstream for utfchar & utfstring
|
||||
//////////////////////////////////////////
|
||||
namespace std
|
||||
{
|
||||
typedef stringstream utfstringstream;
|
||||
typedef ostringstream utfostringstream;
|
||||
typedef istringstream utfistringstream;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
typedef std::basic_string<utfchar> utfstring;
|
||||
|
||||
////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define CopyFloat(dst, src, num) CopyMemory(dst, src, (num) * sizeof(float))
|
||||
|
||||
|
@ -509,10 +509,6 @@
|
||||
RelativePath=".\audio\Transport.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\audio\tstl.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
|
@ -39,9 +39,8 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <core/audio/AudioStream.h>
|
||||
#include <core/PluginFactory.h>
|
||||
#include <core/IPlugin.h>
|
||||
#include <core/PluginFactory.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace musik::square;
|
||||
@ -66,24 +65,24 @@ ConsoleUI::~ConsoleUI()
|
||||
{
|
||||
}
|
||||
|
||||
void ConsoleUI::Print(std::tstring s)
|
||||
void ConsoleUI::Print(utfstring s)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(mutex);
|
||||
|
||||
tcout << "\n*******************************\n\n";
|
||||
std::tcout << s;
|
||||
tcout << "\n*******************************\n" << endl;
|
||||
utfcout << "\n*******************************\n\n";
|
||||
utfcout << s;
|
||||
utfcout << "\n*******************************\n" << endl;
|
||||
}
|
||||
|
||||
void ConsoleUI::Run()
|
||||
{
|
||||
tstring command;
|
||||
utfstring command;
|
||||
|
||||
while (!this->shouldQuit)
|
||||
{
|
||||
this->PrintCommands();
|
||||
cout << "Enter command: ";
|
||||
std::getline(tcin, command); // Need getline to handle spaces!
|
||||
utfcout << UTF("Enter command: ");
|
||||
std::getline(utfcin, command); // Need getline to handle spaces!
|
||||
this->ProcessCommand(command);
|
||||
}
|
||||
}
|
||||
@ -92,17 +91,17 @@ void ConsoleUI::PrintCommands()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(mutex);
|
||||
|
||||
tcout << "Commands:\n";
|
||||
tcout << "\tp [file]: play file (enter full path)\n";
|
||||
tcout << "\ts [n]: stop playing n-th file\n";
|
||||
tcout << "\tl: list currently playing\n";
|
||||
tcout << "\tlp: list loaded plugins\n";
|
||||
tcout << "\tv <p>: set volume to p%\n";
|
||||
tcout << "\tq: quit";
|
||||
tcout << endl;
|
||||
utfcout << "Commands:\n";
|
||||
utfcout << "\tp [file]: play file (enter full path)\n";
|
||||
utfcout << "\ts [n]: stop playing n-th file\n";
|
||||
utfcout << "\tl: list currently playing\n";
|
||||
utfcout << "\tlp: list loaded plugins\n";
|
||||
utfcout << "\tv <p>: set volume to p%\n";
|
||||
utfcout << "\tq: quit";
|
||||
utfcout << endl;
|
||||
}
|
||||
|
||||
void ConsoleUI::ProcessCommand(std::tstring commandString)
|
||||
void ConsoleUI::ProcessCommand(utfstring commandString)
|
||||
{
|
||||
using namespace boost::algorithm;
|
||||
|
||||
@ -110,7 +109,7 @@ void ConsoleUI::ProcessCommand(std::tstring commandString)
|
||||
|
||||
split(args, commandString, is_any_of(" "));
|
||||
|
||||
tstring command = args.size() > 0 ? args[0] : _T("");
|
||||
utfstring command = args.size() > 0 ? args[0] : _T("");
|
||||
args.erase(args.begin());
|
||||
|
||||
if (command == _T("p"))
|
||||
@ -139,13 +138,13 @@ void ConsoleUI::ProcessCommand(std::tstring commandString)
|
||||
}
|
||||
else
|
||||
{
|
||||
tcout << "Unknown command\n";
|
||||
utfcout << "Unknown command\n";
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleUI::PlayFile(Args args)
|
||||
{
|
||||
std::tstring filename;
|
||||
utfstring filename;
|
||||
if (args.size() > 0)
|
||||
{
|
||||
filename = args[0];
|
||||
@ -209,11 +208,11 @@ void ConsoleUI::ListPlaying()
|
||||
|
||||
for (it = overview.begin(); it != overview.end(); ++it)
|
||||
{
|
||||
tcout << *it << '\n';
|
||||
utfcout << *it << '\n';
|
||||
}
|
||||
|
||||
tcout << "------------------\n";
|
||||
tcout << transport.NumOfStreams() << " playing" << endl;
|
||||
utfcout << "------------------\n";
|
||||
utfcout << transport.NumOfStreams() << " playing" << endl;
|
||||
}
|
||||
|
||||
void ConsoleUI::ListPlugins()
|
||||
@ -230,7 +229,7 @@ void ConsoleUI::ListPlugins()
|
||||
PluginList::iterator it = plugins.begin();
|
||||
for ( ; it != plugins.end(); it++)
|
||||
{
|
||||
tcout << (*it)->Name() << '\t' << (*it)->Version() << '\t' << (*it)->Author() << '\n';
|
||||
utfcout << (*it)->Name() << '\t' << (*it)->Version() << '\t' << (*it)->Author() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class AudioStream;
|
||||
|
||||
namespace musik { namespace square {
|
||||
|
||||
typedef std::vector<std::tstring> Args;
|
||||
typedef std::vector<utfstring> Args;
|
||||
|
||||
class ConsoleUI
|
||||
{
|
||||
@ -60,8 +60,8 @@ public: ~ConsoleUI();
|
||||
|
||||
public: void Run();
|
||||
private: void PrintCommands();
|
||||
private: void ProcessCommand(std::tstring commandString);
|
||||
public: void Print(std::tstring s);
|
||||
private: void ProcessCommand(utfstring commandString);
|
||||
public: void Print(utfstring s);
|
||||
|
||||
// Commands
|
||||
private: void PlayFile(Args args);
|
||||
@ -90,9 +90,9 @@ public: static DWORD WINAPI ThreadRun(LPVOID param);
|
||||
#include <sstream>
|
||||
|
||||
template <class T>
|
||||
bool convertString(T& t, const std::tstring& s)
|
||||
bool convertString(T& t, const utfstring& s)
|
||||
{
|
||||
std::tistringstream iss(s);
|
||||
std::utfistringstream iss(s);
|
||||
|
||||
return !(iss >> t).fail();
|
||||
}
|
@ -48,7 +48,7 @@ DummyAudioEventHandler::~DummyAudioEventHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void DummyAudioEventHandler::PrintEvent(std::tstring s)
|
||||
void DummyAudioEventHandler::PrintEvent(utfstring s)
|
||||
{
|
||||
this->cui->Print(_T("EVENT: " + s + _T("\n")));
|
||||
}
|
@ -51,7 +51,7 @@ public: DummyAudioEventHandler(ConsoleUI* c);
|
||||
public: ~DummyAudioEventHandler();
|
||||
|
||||
private: ConsoleUI* cui; // TODO: should probably be interface
|
||||
private: void PrintEvent(std::tstring s);
|
||||
private: void PrintEvent(utfstring s);
|
||||
|
||||
// Slots
|
||||
public: void OnPlaybackStartedOk() { this->PrintEvent(_T("Playback started OK")); };
|
||||
|
62
src/square/config.h
Normal file
62
src/square/config.h
Normal file
@ -0,0 +1,62 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2008, musikCube team
|
||||
//
|
||||
// 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 author nor the names of other 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SQUARE_CONFIG_H
|
||||
#define SQUARE_CONFIG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <core/config.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
#if defined UNICODE || defined _UNICODE
|
||||
# define utfcerr wcerr
|
||||
# define utfcin wcin
|
||||
# define utfclog wclog
|
||||
# define utfcout wcout
|
||||
|
||||
#else // defined UNICODE || defined _UNICODE
|
||||
|
||||
# define utfcerr cerr
|
||||
# define utfcin cin
|
||||
# define utfclog clog
|
||||
# define utfcout cout
|
||||
|
||||
#endif // defined UNICODE || defined _UNICODE
|
||||
} // namespace std
|
||||
|
||||
#endif // SQUARE_CONFIG_H
|
@ -33,25 +33,12 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "core/PluginFactory.h"
|
||||
|
||||
#include "ConsoleUI.h"
|
||||
|
||||
using namespace musik::square;
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
/*
|
||||
HANDLE handle;
|
||||
DWORD threadId;
|
||||
|
||||
handle = CreateThread(NULL, 0, &ConsoleUI::ThreadRun, new ConsoleUI(), NULL, &threadId);
|
||||
|
||||
WaitForSingleObject(handle, INFINITE);
|
||||
|
||||
CloseHandle(handle);
|
||||
*/
|
||||
|
||||
ConsoleUI* instance = new ConsoleUI();
|
||||
instance->Run();
|
||||
delete instance;
|
||||
|
@ -225,6 +225,10 @@
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ConsoleUI.h"
|
||||
>
|
||||
|
@ -8,10 +8,6 @@
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <vld/vld.h>
|
||||
|
||||
#include "vld/vld.h"
|
||||
|
||||
#include "core/audio/tstl.h"
|
||||
#include "config.h"
|
Loading…
Reference in New Issue
Block a user