Skip to content

Commit

Permalink
Fixed some stuff up
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Apr 21, 2023
1 parent 7cff167 commit 0e381e0
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 280 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# Backup
# Ignore backups
*.blend1
*.blend1.meta

# Auto-gen
Assets/YargInput.cs
Expand All @@ -88,4 +89,4 @@ Assets/YargInput.cs
# Rider #
.idea/
Packages/com.thenathannator.hidrogen/
Packages/com.thenathannator.plasticband/
Packages/com.thenathannator.plasticband/
2 changes: 1 addition & 1 deletion Assets/Art/Materials/PlayMode/Note_Tap.mat
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Note_Metal
m_Name: Note_Tap
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
Expand Down
7 changes: 0 additions & 7 deletions Assets/Art/Meshes/Notes.blend1.meta

This file was deleted.

19 changes: 10 additions & 9 deletions Assets/Prefabs/RealGuitarNote.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RectTransform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 396386252373935444}
m_LocalRotation: {x: 0.56322813, y: -0, z: -0, w: 0.8263015}
m_LocalPosition: {x: 0, y: 0, z: 0.03}
m_LocalPosition: {x: 0, y: 0, z: 0.015}
m_LocalScale: {x: 0.17877747, y: 0.19130976, z: 0.17877747}
m_ConstrainProportionsScale: 0
m_Children: []
Expand All @@ -35,8 +35,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 68.559, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0.107}
m_SizeDelta: {x: 1.5, y: 1.3}
m_AnchoredPosition: {x: 0, y: 0.166}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &3746261134333683177
MeshRenderer:
Expand Down Expand Up @@ -100,7 +100,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0
m_text: 1
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: bd78233bc3a8ea940a15e0d7ce6a701a, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: 9d454ccc7950ea045924c7d2411604a8, type: 2}
Expand All @@ -127,12 +127,12 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 15
m_fontSizeBase: 15
m_fontSize: 12.5
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down Expand Up @@ -229,6 +229,7 @@ MonoBehaviour:
meshRendererMiddleIndices: 0200000002000000
noteGroup: {fileID: 1397812567785855241}
hopoGroup: {fileID: 1294466957868725440}
tapGroup: {fileID: 0}
fullGroup: {fileID: 5879953073027725293}
fretNumber: {fileID: 5134052872940096443}
lineRenderer: {fileID: 5864461325193466425}
Expand Down
48 changes: 24 additions & 24 deletions Assets/Prefabs/RealGuitarTrack.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9834,7 +9834,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0.5, y: 0.1}
m_SizeDelta: {x: 1.3, y: 1.3}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &2143939448389825635
MeshRenderer:
Expand Down Expand Up @@ -9928,9 +9928,9 @@ MonoBehaviour:
m_fontSize: 13
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down Expand Up @@ -49050,7 +49050,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -0.1666667, y: 0.1}
m_SizeDelta: {x: 1.3, y: 1.3}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &2644446649672142872
MeshRenderer:
Expand Down Expand Up @@ -49144,9 +49144,9 @@ MonoBehaviour:
m_fontSize: 13
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down Expand Up @@ -88298,7 +88298,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -0.8333333, y: 0.1}
m_SizeDelta: {x: 1.3, y: 1.3}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &7895565979112695365
MeshRenderer:
Expand Down Expand Up @@ -88392,9 +88392,9 @@ MonoBehaviour:
m_fontSize: 13
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down Expand Up @@ -88470,7 +88470,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -0.5, y: 0.1}
m_SizeDelta: {x: 1.3, y: 1.3}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &2444183623338863627
MeshRenderer:
Expand Down Expand Up @@ -88564,9 +88564,9 @@ MonoBehaviour:
m_fontSize: 13
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down Expand Up @@ -161641,7 +161641,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0.1666667, y: 0.1}
m_SizeDelta: {x: 1.3, y: 1.3}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &6118850895532487502
MeshRenderer:
Expand Down Expand Up @@ -161735,9 +161735,9 @@ MonoBehaviour:
m_fontSize: 13
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down Expand Up @@ -205604,7 +205604,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0.8333333, y: 0.1}
m_SizeDelta: {x: 1.3, y: 1.3}
m_SizeDelta: {x: 1.5, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &4082768599485258066
MeshRenderer:
Expand Down Expand Up @@ -205698,9 +205698,9 @@ MonoBehaviour:
m_fontSize: 13
m_fontSizeBase: 13
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 8
m_fontSizeMax: 10
m_enableAutoSizing: 1
m_fontSizeMin: 12
m_fontSizeMax: 22
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 1024
Expand Down
60 changes: 28 additions & 32 deletions Assets/Script/Audio/Bass/BassStemChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
using ManagedBass;
using ManagedBass.DirectX8;
using ManagedBass.Fx;
using UnityEngine;

namespace YARG {
public class BassStemChannel : IStemChannel {

private const EffectType REVERB_TYPE = EffectType.DXReverb;

public SongStem Stem { get; }
public double LengthD { get; private set; }

public double Volume { get; private set; }

public int StreamHandle { get; private set; }

private readonly string _path;
Expand All @@ -26,7 +25,7 @@ public class BassStemChannel : IStemChannel {
private readonly DSPProcedure _dspGain;

private double _lastStemVolume;

private bool _disposed;

public BassStemChannel(IAudioManager manager, string path, SongStem stem) {
Expand All @@ -39,10 +38,10 @@ public BassStemChannel(IAudioManager manager, string path, SongStem stem) {
_lastStemVolume = _manager.GetVolumeSetting(Stem);
_effects = new Dictionary<EffectType, int>();
_dspHandles = new Dictionary<DSPType, int>();

_dspGain += GainDSP;
}

~BassStemChannel() {
Dispose(false);
}
Expand All @@ -52,10 +51,10 @@ public int Load(bool isSpeedUp, float speed) {
if (StreamHandle != 0) {
return 0;
}

int streamHandle = Bass.CreateStream(_path, 0, 0, BassFlags.Prescan | BassFlags.Decode | BassFlags.AsyncFile);
if (streamHandle == 0) {
return (int)Bass.LastError;
return (int) Bass.LastError;
}

const BassFlags flags = BassFlags.SampleOverrideLowestVolume | BassFlags.Decode | BassFlags.FxFreeSource;
Expand All @@ -78,7 +77,7 @@ public int Load(bool isSpeedUp, float speed) {
}

LengthD = GetLengthInSeconds();

return 0;
}

Expand All @@ -88,24 +87,21 @@ public void SetVolume(double newVolume) {
}

double volumeSetting = _manager.GetVolumeSetting(Stem);

double oldBassVol = _lastStemVolume * Volume;
double newBassVol = volumeSetting * newVolume;

// Values are the same, no need to change
if (Math.Abs(oldBassVol - newBassVol) < double.Epsilon) {
Debug.Log($"{Stem} values same");
return;
}

Debug.Log($"Updated {Stem} volume to {newVolume}");


Volume = newVolume;
_lastStemVolume = volumeSetting;

Bass.ChannelSetAttribute(StreamHandle, ChannelAttribute.Volume, newBassVol);
}

public void SetReverb(bool reverb) {
if (reverb) {
// Reverb already applied
Expand All @@ -131,7 +127,7 @@ public void SetReverb(bool reverb) {
_dspHandles.Remove(DSPType.Gain);
}
}

public double GetPosition() {
return Bass.ChannelBytes2Seconds(StreamHandle, Bass.ChannelGetPosition(StreamHandle));
}
Expand All @@ -140,44 +136,44 @@ public double GetLengthInSeconds() {
if (StreamHandle == 0) {
return 0;
}

long length = Bass.ChannelGetLength(StreamHandle);

if (length == -1) {
return (double) Bass.LastError;
}

double seconds = Bass.ChannelBytes2Seconds(StreamHandle, length);

if (seconds < 0) {
return (double) Bass.LastError;
}

return seconds;
}

public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool disposing) {
if (!_disposed) {
// Free managed resources here
if (disposing) {

}

// Free unmanaged resources here
if (StreamHandle != 0) {
Bass.StreamFree(StreamHandle);
StreamHandle = 0;
}

_disposed = true;
}
}

private int AddReverbToChannel() {
// Set reverb FX
int reverbHandle = Bass.ChannelSetFX(StreamHandle, REVERB_TYPE, 0);
Expand All @@ -202,7 +198,7 @@ private int AddReverbToChannel() {

return !Bass.FXSetParameters(reverbHandle, reverbParams) ? 0 : reverbHandle;
}

private static unsafe void GainDSP(int handle, int channel, IntPtr buffer, int length, IntPtr user) {
var bufferPtr = (float*) buffer;
int samples = length / 4;
Expand Down
Loading

0 comments on commit 0e381e0

Please sign in to comment.