Watch
2
0
Fork
You've already forked raylib-cs
0

chore: clean up linter warnings

This commit is contained in:
tiger tiger tiger 2026-07-29 19:58:47 +02:00
commit dfc34997bc
No known key found for this signature in database
217 changed files with 1863 additions and 1077 deletions

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public unsafe partial class AmpEnvelope : IExample
@ -89,9 +85,15 @@ public unsafe partial class AmpEnvelope : IExample
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.Space)) env.State = ADSRState.Attack;
if (IsKeyPressed(KeyboardKey.Space))
{
env.State = ADSRState.Attack;
}
if (IsKeyReleased(KeyboardKey.Space) && (env.State != ADSRState.Idle)) env.State = ADSRState.Release;
if (IsKeyReleased(KeyboardKey.Space) && (env.State != ADSRState.Idle))
{
env.State = ADSRState.Release;
}
if (IsAudioStreamProcessed(stream))
{
@ -106,7 +108,11 @@ public unsafe partial class AmpEnvelope : IExample
else
{
// Clear buffer if silent to avoid looping noise
for (int i = 0; i < BUFFER_SIZE; i++) buffer[i] = 0;
for (int i = 0; i < BUFFER_SIZE; i++)
{
buffer[i] = 0;
}
audioTime = 0.0f;
}
@ -116,7 +122,10 @@ public unsafe partial class AmpEnvelope : IExample
}
}
if (!IsAudioStreamPlaying(stream)) PlayAudioStream(stream);
if (!IsAudioStreamPlaying(stream))
{
PlayAudioStream(stream);
}
//----------------------------------------------------------------------------------
// Draw

View file

@ -15,10 +15,8 @@
*
********************************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
@ -60,7 +58,10 @@ public unsafe partial class MixedProcessor : IExample
}
// Moving history to the left
for (int i = 0; i < 399; i++) averageVolume[i] = averageVolume[i + 1];
for (int i = 0; i < 399; i++)
{
averageVolume[i] = averageVolume[i + 1];
}
averageVolume[399] = average; // Adding last average value
}
@ -88,13 +89,30 @@ public unsafe partial class MixedProcessor : IExample
// Modify processing variables
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.Left)) exponent -= 0.05f;
if (IsKeyPressed(KeyboardKey.Right)) exponent += 0.05f;
if (IsKeyPressed(KeyboardKey.Left))
{
exponent -= 0.05f;
}
if (exponent <= 0.5f) exponent = 0.5f;
if (exponent >= 3.0f) exponent = 3.0f;
if (IsKeyPressed(KeyboardKey.Right))
{
exponent += 0.05f;
}
if (IsKeyPressed(KeyboardKey.Space)) PlaySound(sound);
if (exponent <= 0.5f)
{
exponent = 0.5f;
}
if (exponent >= 3.0f)
{
exponent = 3.0f;
}
if (IsKeyPressed(KeyboardKey.Space))
{
PlaySound(sound);
}
// Draw
//----------------------------------------------------------------------------------

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class ModulePlaying : IExample

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class MusicStreamDemo : IExample

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public unsafe partial class RawStream : IExample
@ -71,26 +67,40 @@ public unsafe partial class RawStream : IExample
if (IsKeyDown(KeyboardKey.Up))
{
newSineFrequency += 10;
if (newSineFrequency > 12500) newSineFrequency = 12500;
if (newSineFrequency > 12500)
{
newSineFrequency = 12500;
}
}
if (IsKeyDown(KeyboardKey.Down))
{
newSineFrequency -= 10;
if (newSineFrequency < 20) newSineFrequency = 20;
if (newSineFrequency < 20)
{
newSineFrequency = 20;
}
}
if (IsKeyDown(KeyboardKey.Left))
{
pan -= 0.01f;
if (pan < -1.0f) pan = -1.0f;
if (pan < -1.0f)
{
pan = -1.0f;
}
SetAudioStreamPan(stream, pan);
}
if (IsKeyDown(KeyboardKey.Right))
{
pan += 0.01f;
if (pan > 1.0f) pan = 1.0f;
if (pan > 1.0f)
{
pan = 1.0f;
}
SetAudioStreamPan(stream, pan);
}

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class SoundLoading : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class SoundMulti : IExample
@ -42,7 +40,10 @@ public partial class SoundMulti : IExample
soundArray[0] = LoadSound("resources/audio/sound.wav");
// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
for (int i = 1; i < MAX_SOUNDS; i++)
{
soundArray[i] = LoadSoundAlias(soundArray[0]);
}
currentSound = 0; // Set the sound list to the start
}
@ -57,7 +58,10 @@ public partial class SoundMulti : IExample
currentSound++; // Increment the sound slot
// If the sound slot is out of bounds, go back to 0
if (currentSound >= MAX_SOUNDS) currentSound = 0;
if (currentSound >= MAX_SOUNDS)
{
currentSound = 0;
}
// NOTE: Another approach would be to look at the list for the first sound
// that is not playing and use that slot
@ -78,7 +82,11 @@ public partial class SoundMulti : IExample
public void Unload()
{
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
for (int i = 1; i < MAX_SOUNDS; i++)
{
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
}
UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class SoundPositioning : IExample
@ -67,7 +63,10 @@ public partial class SoundPositioning : IExample
SetSoundPosition(camera, sound, spherePos, 1.0f);
if (!IsSoundPlaying(sound)) PlaySound(sound);
if (!IsSoundPlaying(sound))
{
PlaySound(sound);
}
//----------------------------------------------------------------------------------
// Draw
@ -112,7 +111,10 @@ public partial class SoundPositioning : IExample
// Reduce volume for sounds behind the listener
float dotProduct = Vector3.Dot(forward, normalizedDirection);
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct * 0.5f);
if (dotProduct < 0.0f)
{
attenuation *= (1.0f + dotProduct * 0.5f);
}
// Set stereo panning based on sound position relative to listener
float pan = 0.5f + 0.5f * Vector3.Dot(normalizedDirection, right);

View file

@ -20,11 +20,8 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
@ -105,31 +102,61 @@ public unsafe partial class StreamCallback : IExample
if (IsKeyDown(KeyboardKey.Up))
{
newWaveFrequency += 10;
if (newWaveFrequency > 12500) newWaveFrequency = 12500;
if (newWaveFrequency > 12500)
{
newWaveFrequency = 12500;
}
}
if (IsKeyDown(KeyboardKey.Down))
{
newWaveFrequency -= 10;
if (newWaveFrequency < 20) newWaveFrequency = 20;
if (newWaveFrequency < 20)
{
newWaveFrequency = 20;
}
}
if (IsKeyPressed(KeyboardKey.Left))
{
if (waveType == WaveType.Sine) waveType = WaveType.Sawtooth;
else if (waveType == WaveType.Square) waveType = WaveType.Sine;
else if (waveType == WaveType.Triangle) waveType = WaveType.Square;
else waveType = WaveType.Triangle;
if (waveType == WaveType.Sine)
{
waveType = WaveType.Sawtooth;
}
else if (waveType == WaveType.Square)
{
waveType = WaveType.Sine;
}
else if (waveType == WaveType.Triangle)
{
waveType = WaveType.Square;
}
else
{
waveType = WaveType.Triangle;
}
SetWaveCallback();
}
if (IsKeyPressed(KeyboardKey.Right))
{
if (waveType == WaveType.Sine) waveType = WaveType.Square;
else if (waveType == WaveType.Square) waveType = WaveType.Triangle;
else if (waveType == WaveType.Triangle) waveType = WaveType.Sawtooth;
else waveType = WaveType.Sine;
if (waveType == WaveType.Sine)
{
waveType = WaveType.Square;
}
else if (waveType == WaveType.Square)
{
waveType = WaveType.Triangle;
}
else if (waveType == WaveType.Triangle)
{
waveType = WaveType.Sawtooth;
}
else
{
waveType = WaveType.Sine;
}
SetWaveCallback();
}
@ -197,8 +224,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
@ -222,8 +256,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
@ -247,8 +288,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
@ -272,8 +320,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
public static int Main()

View file

@ -15,7 +15,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
@ -87,30 +86,51 @@ public unsafe partial class StreamEffects : IExample
{
pause = !pause;
if (pause) PauseMusicStream(music);
else ResumeMusicStream(music);
if (pause)
{
PauseMusicStream(music);
}
else
{
ResumeMusicStream(music);
}
}
// Add/Remove effect: lowpass filter
if (IsKeyPressed(KeyboardKey.F))
{
enableEffectLPF = !enableEffectLPF;
if (enableEffectLPF) AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
else DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
if (enableEffectLPF)
{
AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
}
else
{
DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
}
}
// Add/Remove effect: delay
if (IsKeyPressed(KeyboardKey.D))
{
enableEffectDelay = !enableEffectDelay;
if (enableEffectDelay) AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
else DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
if (enableEffectDelay)
{
AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
}
else
{
DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
}
}
// Get normalized time played for current music stream
timePlayed = GetMusicTimePlayed(music) / GetMusicTimeLength(music);
if (timePlayed > 1.0f) timePlayed = 1.0f; // Make sure time played is no longer than music
if (timePlayed > 1.0f)
{
timePlayed = 1.0f; // Make sure time played is no longer than music
}
//----------------------------------------------------------------------------------
// Draw
@ -180,14 +200,20 @@ public unsafe partial class StreamEffects : IExample
float leftDelay = delay[delayReadIndex++]; // ERROR: Reading buffer -> WHY??? Maybe thread related???
float rightDelay = delay[delayReadIndex++];
if (delayReadIndex == delayBufferSize) delayReadIndex = 0;
if (delayReadIndex == delayBufferSize)
{
delayReadIndex = 0;
}
bufferData[i] = 0.5f * bufferData[i] + 0.5f * leftDelay;
bufferData[i + 1] = 0.5f * bufferData[i + 1] + 0.5f * rightDelay;
delay[delayWriteIndex++] = bufferData[i];
delay[delayWriteIndex++] = bufferData[i + 1];
if (delayWriteIndex == delayBufferSize) delayWriteIndex = 0;
if (delayWriteIndex == delayBufferSize)
{
delayWriteIndex = 0;
}
}
}
}