forked from jeff-1amstudios/OpenC1
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c84d25a
commit 93ade32
Showing
4,698 changed files
with
921,730 additions
and
18 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
\.vs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
rmdir /S /Q ReleasePackage | ||
mkdir ReleasePackage | ||
xcopy /S OpenC1\bin\x86\Release\* ReleasePackage | ||
copy Engine\Lib\Microsoft.DirectX.* ReleasePackage | ||
cd ReleasePackage | ||
mkdir tmp | ||
c:\progra~2\Microsoft\ilmerge\ilmerge.exe /out:tmp\OpenC1.exe OpenC1.exe 1amstudiosEngine.dll Ionic.Zip.Reduced.dll | ||
del OpenC1.* | ||
del 1amstudiosEngine.* | ||
del Ionic.Zip.Reduced.dll | ||
copy tmp\* . | ||
rmdir /S /Q tmp | ||
rmdir /S /Q Lib | ||
copy ..\license.txt . | ||
copy ..\readme.txt . | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace OneAmEngine.Audio | ||
{ | ||
public interface IListener | ||
{ | ||
void SetOrientation(Vector3 forward); | ||
Matrix Orientation { set; } | ||
Vector3 Position { get; set; } | ||
Vector3 Velocity { set; } | ||
float DistanceFactor { set; } | ||
float RolloffFactor { set; } | ||
void BeginUpdate(); | ||
void CommitChanges(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace OneAmEngine.Audio | ||
{ | ||
|
||
public interface ISound | ||
{ | ||
int Id { get; set; } | ||
object Owner { get; set; } | ||
float Duration { get; } | ||
float Volume { get; set; } | ||
void Pause(); | ||
void Stop(); | ||
void Reset(); | ||
void Play(bool loop); | ||
Vector3 Position { get; set; } | ||
Vector3 Velocity { set; } | ||
int Frequency { set; } | ||
bool IsPlaying { get; } | ||
float MinimumDistance { get; set; } | ||
float MaximumDistance { get; set; } | ||
bool MuteAtMaximumDistance { get; set; } | ||
// bool | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace OneAmEngine.Audio | ||
{ | ||
public interface ISoundEngine | ||
{ | ||
void SetDefaultVolume(int volume); | ||
IListener GetListener(); | ||
ISound Load(string name, bool is3d); | ||
//void Play(ISound sound, float duration); | ||
void Register3dSound(ISound sound); | ||
void Unregister3dSound(ISound sound); | ||
void Update(); | ||
void StopAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.DirectX.DirectSound; | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace OneAmEngine.Audio | ||
{ | ||
class MdxListener : IListener | ||
{ | ||
Listener3D _listener; | ||
|
||
public MdxListener(Device device) | ||
{ | ||
BufferDescription desc = new BufferDescription(); | ||
desc.PrimaryBuffer = true; | ||
desc.Control3D = true; | ||
desc.Mute3DAtMaximumDistance = true; | ||
|
||
Microsoft.DirectX.DirectSound.Buffer buffer = new Microsoft.DirectX.DirectSound.Buffer(desc, device); | ||
_listener = new Listener3D(buffer); | ||
|
||
Orientation = Matrix.Identity; | ||
} | ||
|
||
public Matrix Orientation | ||
{ | ||
set | ||
{ | ||
Listener3DOrientation orientation = _listener.Orientation; | ||
orientation.Front = MdxHelpers.ToMdx(Vector3.Normalize(value.Forward)); | ||
orientation.Top = MdxHelpers.ToMdx(Vector3.Normalize(value.Up)); | ||
_listener.Orientation = orientation; | ||
} | ||
} | ||
|
||
public void SetOrientation(Vector3 forward) | ||
{ | ||
Listener3DOrientation orientation = _listener.Orientation; | ||
orientation.Front = MdxHelpers.ToMdx(forward); | ||
orientation.Top = MdxHelpers.ToMdx(Vector3.Up); | ||
_listener.Orientation = orientation; | ||
} | ||
|
||
public Vector3 Position | ||
{ | ||
get { return MdxHelpers.ToXna(_listener.Position); } | ||
set { _listener.Position = MdxHelpers.ToMdx(value); } | ||
} | ||
|
||
public Vector3 Velocity | ||
{ | ||
set { _listener.Velocity = MdxHelpers.ToMdx(value); } | ||
} | ||
|
||
public float DistanceFactor | ||
{ | ||
set { _listener.DistanceFactor = value; } | ||
} | ||
|
||
public float RolloffFactor | ||
{ | ||
set { _listener.RolloffFactor = value; } | ||
} | ||
|
||
public void BeginUpdate() | ||
{ | ||
_listener.Deferred = true; | ||
} | ||
|
||
public void CommitChanges() | ||
{ | ||
_listener.CommitDeferredSettings(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.DirectX.DirectSound; | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace OneAmEngine.Audio | ||
{ | ||
class MdxSound : ISound | ||
{ | ||
SecondaryBuffer _buffer; | ||
Buffer3D _buffer3d; | ||
bool _is3d; | ||
|
||
public int Id { get; set; } | ||
public object Owner { get; set; } | ||
public bool MuteAtMaximumDistance { get; set; } | ||
|
||
internal MdxSound(Device device, string filename, bool is3d) | ||
{ | ||
BufferDescription desc = new BufferDescription(); | ||
|
||
if (is3d) | ||
{ | ||
desc.Control3D = true; | ||
desc.Guid3DAlgorithm = DSoundHelper.Guid3DAlgorithmDefault; | ||
desc.Mute3DAtMaximumDistance = true; | ||
} | ||
desc.ControlVolume = true; | ||
desc.ControlFrequency = true; | ||
_buffer = new SecondaryBuffer(filename, desc, device); | ||
|
||
if (is3d) | ||
{ | ||
_buffer3d = new Buffer3D(_buffer); | ||
_buffer3d.Mode = Mode3D.Normal; | ||
_is3d = true; | ||
} | ||
} | ||
|
||
public float Volume | ||
{ | ||
get { return _buffer.Volume; } | ||
set { _buffer.Volume = (int)value; } | ||
} | ||
|
||
public float Duration | ||
{ | ||
get | ||
{ | ||
return (float)_buffer.Caps.BufferBytes / (float)_buffer.Format.SamplesPerSecond; | ||
} | ||
} | ||
|
||
public Vector3 Position | ||
{ | ||
get | ||
{ | ||
if (_buffer3d == null) return Vector3.Zero; | ||
return MdxHelpers.ToXna(_buffer3d.Position); | ||
} | ||
set | ||
{ | ||
if (_buffer3d == null) return; | ||
_buffer3d.Position = MdxHelpers.ToMdx(value); | ||
} | ||
} | ||
|
||
public Vector3 Velocity | ||
{ | ||
set | ||
{ | ||
if (_buffer3d == null) return; | ||
_buffer3d.Velocity = MdxHelpers.ToMdx(value); | ||
} | ||
} | ||
|
||
public int Frequency | ||
{ | ||
set { _buffer.Frequency = value; } | ||
} | ||
|
||
public void Play(bool loop) | ||
{ | ||
_buffer.Play(0, loop ? BufferPlayFlags.Looping : BufferPlayFlags.Default); | ||
if (_is3d && loop && MuteAtMaximumDistance) | ||
{ | ||
Engine.Audio.Register3dSound(this); | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
_buffer.Stop(); | ||
_buffer.SetCurrentPosition(0); | ||
Engine.Audio.Unregister3dSound(this); | ||
} | ||
|
||
public void Pause() | ||
{ | ||
_buffer.Stop(); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
_buffer.SetCurrentPosition(0); | ||
} | ||
|
||
public bool IsPlaying | ||
{ | ||
get | ||
{ | ||
return _buffer.Status.Playing; | ||
} | ||
} | ||
|
||
public float MaximumDistance | ||
{ | ||
get | ||
{ | ||
if (_buffer3d == null) return 0; | ||
return _buffer3d.MaxDistance; | ||
} | ||
set | ||
{ | ||
if (_buffer3d == null) return; | ||
_buffer3d.MaxDistance = value; | ||
} | ||
} | ||
|
||
public float MinimumDistance | ||
{ | ||
get | ||
{ | ||
if (_buffer3d == null) return 0; | ||
return _buffer3d.MinDistance; | ||
} | ||
set | ||
{ | ||
if (_buffer3d == null) return; | ||
_buffer3d.MinDistance = value; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.