Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamLCobb committed Jun 9, 2016
0 parents commit c3e2816
Show file tree
Hide file tree
Showing 742 changed files with 65,012 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
# OS X temporary files that should never be committed
#
# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.DS_Store

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.Trashes

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

*.swp

#
# *.lock - this is used and abused by many editors for many different things.
# For the main ones I use (e.g. Eclipse), it should be excluded
# from source-control, but YMMV.
# (lock files are usually local-only file-synchronization on the local FS that should NOT go in git)
# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations!
#
# In particular, if you're using CocoaPods, you'll want to comment-out this line:
*.lock


####
# Xcode temporary files that should never be committed
#
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...

*~.nib


####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"

DerivedData/

# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"

build/


#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
# saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
# ..but if you're in the 1%, comment out the line "*.pbxuser"

# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html

*.pbxuser

# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode1v3

# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode2v3

# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file

*.perspectivev3

# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3


# As per build/ and DerivedData/, this ought to have a trailing slash
xcuserdata/
xcshareddata/
47 changes: 47 additions & 0 deletions Dolphin/Include/AudioCommon/AOSoundStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <atomic>
#include <mutex>
#include <thread>

#include "AudioCommon/SoundStream.h"
#include "Common/Event.h"
#include "Common/Thread.h"

#if defined(HAVE_AO) && HAVE_AO
#include <ao/ao.h>
#endif

class AOSound final : public SoundStream
{
#if defined(HAVE_AO) && HAVE_AO
std::thread thread;
std::atomic<bool> m_run_thread;
std::mutex soundCriticalSection;
Common::Event soundSyncEvent;

int buf_size;

ao_device *device;
ao_sample_format format;
int default_driver;

short realtimeBuffer[1024 * 1024];

public:
bool Start() override;
void SoundLoop() override;
void Stop() override;
void Update() override;

static bool isValid()
{
return true;
}

#endif
};
66 changes: 66 additions & 0 deletions Dolphin/Include/AudioCommon/AlsaSoundStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <atomic>
#include <condition_variable>
#include <mutex>
#include <thread>

#if defined(HAVE_ALSA) && HAVE_ALSA
#include <alsa/asoundlib.h>
#endif

#include "AudioCommon/SoundStream.h"
#include "Common/CommonTypes.h"

class AlsaSound final : public SoundStream
{
#if defined(HAVE_ALSA) && HAVE_ALSA
public:
AlsaSound();

bool Start() override;
void SoundLoop() override;
void Stop() override;
void Update() override;
void Clear(bool) override;

static bool isValid()
{
return true;
}

private:
// maximum number of frames the buffer can hold
static constexpr size_t BUFFER_SIZE_MAX = 8192;

// minimum number of frames to deliver in one transfer
static constexpr u32 FRAME_COUNT_MIN = 256;

// number of channels per frame
static constexpr u32 CHANNEL_COUNT = 2;

enum class ALSAThreadStatus
{
RUNNING,
PAUSED,
STOPPING,
STOPPED,
};

bool AlsaInit();
void AlsaShutdown();

s16 mix_buffer[BUFFER_SIZE_MAX * CHANNEL_COUNT];
std::thread thread;
std::atomic<ALSAThreadStatus> m_thread_status;
std::condition_variable cv;
std::mutex cv_m;

snd_pcm_t *handle;
unsigned int frames_to_deliver;
#endif
};
28 changes: 28 additions & 0 deletions Dolphin/Include/AudioCommon/AudioCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "AudioCommon/SoundStream.h"
#include "Common/CommonTypes.h"


class CMixer;

extern SoundStream *g_sound_stream;

namespace AudioCommon
{
SoundStream* InitSoundStream();
void ShutdownSoundStream();
std::vector<std::string> GetSoundBackends();
void UpdateSoundStream();
void ClearAudioBuffer(bool mute);
void SendAIBuffer(short* samples, unsigned int num_samples);
void StartAudioDump();
void StopAudioDump();
void IncreaseVolume(unsigned short offset);
void DecreaseVolume(unsigned short offset);
void ToggleMuteVolume();
}
38 changes: 38 additions & 0 deletions Dolphin/Include/AudioCommon/CoreAudioSoundStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#ifdef __APPLE__
#include <AudioUnit/AudioUnit.h>
#endif

#include "AudioCommon/SoundStream.h"

class CoreAudioSound final : public SoundStream
{
#ifdef __APPLE__
public:
bool Start() override;
void SetVolume(int volume) override;
void SoundLoop() override;
void Stop() override;
void Update() override;

static bool isValid()
{
return true;
}

private:
AudioUnit audioUnit;
int m_volume;

static OSStatus callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData);
#endif
};
8 changes: 8 additions & 0 deletions Dolphin/Include/AudioCommon/DPL2Decoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

void DPL2Decode(float *samples, int numsamples, float *out);
void DPL2Reset();
86 changes: 86 additions & 0 deletions Dolphin/Include/AudioCommon/Mixer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <array>
#include <atomic>

#include "AudioCommon/WaveFile.h"
#include "Common/CommonTypes.h"

class CMixer final
{
public:
explicit CMixer(unsigned int BackendSampleRate);
~CMixer();

// Called from audio threads
unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true);

// Called from main thread
void PushSamples(const short* samples, unsigned int num_samples);
void PushStreamingSamples(const short* samples, unsigned int num_samples);
void PushWiimoteSpeakerSamples(const short* samples, unsigned int num_samples, unsigned int sample_rate);
unsigned int GetSampleRate() const { return m_sampleRate; }

void SetDMAInputSampleRate(unsigned int rate);
void SetStreamInputSampleRate(unsigned int rate);
void SetStreamingVolume(unsigned int lvolume, unsigned int rvolume);
void SetWiimoteSpeakerVolume(unsigned int lvolume, unsigned int rvolume);

void StartLogDTKAudio(const std::string& filename);
void StopLogDTKAudio();

void StartLogDSPAudio(const std::string& filename);
void StopLogDSPAudio();

float GetCurrentSpeed() const { return m_speed.load(); }
void UpdateSpeed(float val) { m_speed.store(val); }

private:
static constexpr u32 MAX_SAMPLES = 1024 * 4; // 128 ms
static constexpr u32 INDEX_MASK = MAX_SAMPLES * 2 - 1;
static constexpr int MAX_FREQ_SHIFT = 200; // Per 32000 Hz
static constexpr float CONTROL_FACTOR = 0.2f;
static constexpr u32 CONTROL_AVG = 32; // In freq_shift per FIFO size offset

class MixerFifo final
{
public:
MixerFifo(CMixer* mixer, unsigned sample_rate)
: m_mixer(mixer)
, m_input_sample_rate(sample_rate)
{
}
void PushSamples(const short* samples, unsigned int num_samples);
unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true);
void SetInputSampleRate(unsigned int rate);
void SetVolume(unsigned int lvolume, unsigned int rvolume);
private:
CMixer* m_mixer;
unsigned m_input_sample_rate;
std::array<short, MAX_SAMPLES * 2> m_buffer{};
std::atomic<u32> m_indexW{0};
std::atomic<u32> m_indexR{0};
// Volume ranges from 0-256
std::atomic<s32> m_LVolume{256};
std::atomic<s32> m_RVolume{256};
float m_numLeftI = 0.0f;
u32 m_frac = 0;
};
MixerFifo m_dma_mixer{this, 32000};
MixerFifo m_streaming_mixer{this, 48000};
MixerFifo m_wiimote_speaker_mixer{this, 3000};
unsigned int m_sampleRate;

WaveFileWriter m_wave_writer_dtk;
WaveFileWriter m_wave_writer_dsp;

bool m_log_dtk_audio = false;
bool m_log_dsp_audio = false;

// Current rate of emulation (1.0 = 100% speed)
std::atomic<float> m_speed{0.0f};
};
27 changes: 27 additions & 0 deletions Dolphin/Include/AudioCommon/NullSoundStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <array>
#include "AudioCommon/SoundStream.h"

class NullSound final : public SoundStream
{
public:
bool Start() override;
void SoundLoop() override;
void SetVolume(int volume) override;
void Stop() override;
void Clear(bool mute) override;
void Update() override;

static bool isValid() { return true; }

private:
static constexpr size_t BUFFER_SIZE = 48000 * 4 / 32;

// Playback position
std::array<short, BUFFER_SIZE / sizeof(short)> m_realtime_buffer;
};
Loading

0 comments on commit c3e2816

Please sign in to comment.