![]() |
VOOZH | about |
dotnet add package BenMakesGames.PlayPlayMini.BeepBoop --version 0.14.0
NuGet\Install-Package BenMakesGames.PlayPlayMini.BeepBoop -Version 0.14.0
<PackageReference Include="BenMakesGames.PlayPlayMini.BeepBoop" Version="0.14.0" />
<PackageVersion Include="BenMakesGames.PlayPlayMini.BeepBoop" Version="0.14.0" />Directory.Packages.props
<PackageReference Include="BenMakesGames.PlayPlayMini.BeepBoop" />Project file
paket add BenMakesGames.PlayPlayMini.BeepBoop --version 0.14.0
#r "nuget: BenMakesGames.PlayPlayMini.BeepBoop, 0.14.0"
#:package BenMakesGames.PlayPlayMini.BeepBoop@0.14.0
#addin nuget:?package=BenMakesGames.PlayPlayMini.BeepBoop&version=0.14.0Install as a Cake Addin
#tool nuget:?package=BenMakesGames.PlayPlayMini.BeepBoop&version=0.14.0Install as a Cake Tool
An extension for PlayPlayMini which adds methods for generating wave forms on the fly, with support for attack and decay.
This library is in the early stages of development, and has some known issues (for example, it refuses to play notes after a while, for reasons which are still unclear to me). It is not suitable for use in a final product.
🧚 Hey, listen! You can support my development of open-source software on Patreon
Here is an example PlayPlayMini game state which lets users play notes by pressing keys on their keyboard:
using System.Diagnostics;
using BenMakesGames.PlayPlayMini;
using BenMakesGames.PlayPlayMini.BeepBoop;
using BenMakesGames.PlayPlayMini.Services;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace BeepBoopTest.GameStates;
public sealed class Playing: GameState
{
private KeyboardManager Keyboard { get; }
private SoundManager Sounds { get; }
private GraphicsManager Graphics { get; }
private WaveType WaveType { get; set; } = WaveType.Square;
private List<char> NoteHistory { get; } = new();
public Playing(KeyboardManager keyboard, SoundManager sounds, GraphicsManager graphics)
{
Keyboard = keyboard;
Sounds = sounds;
Graphics = graphics;
}
public override void Draw(GameTime gameTime)
{
Graphics.Clear(Color.Black);
// assumes you have loaded a font called "Font"; if not, comment these lines out
Graphics.DrawText("Font", 2, 2, "Press A, S, D, F, G, H, J, K, L to play notes.", Color.White);
Graphics.DrawText("Font", 2, 12, "Press 1, 2, 3, 4 to select wave shape.", Color.White);
Graphics.DrawText("Font", 2, 22, $"Current wave shape: {WaveType}.", Color.White);
for(int i = 0; i < NoteHistory.Count; i++)
Graphics.DrawText("Font", 2 + (i * 6), 42, NoteHistory[i], i == NoteHistory.Count - 1 ? Color.White : Color.SkyBlue);
}
public override void Input(GameTime gameTime)
{
if(Keyboard.PressedKey(Keys.D1))
WaveType = WaveType.Square;
else if(Keyboard.PressedKey(Keys.D2))
WaveType = WaveType.Sawtooth;
else if(Keyboard.PressedKey(Keys.D3))
WaveType = WaveType.Triangle;
else if(Keyboard.PressedKey(Keys.D4))
WaveType = WaveType.Sine;
if(Keyboard.PressedKey(Keys.A)) PlaySound(Note.C);
if(Keyboard.PressedKey(Keys.S)) PlaySound(Note.D);
if(Keyboard.PressedKey(Keys.D)) PlaySound(Note.E);
if(Keyboard.PressedKey(Keys.F)) PlaySound(Note.F);
if(Keyboard.PressedKey(Keys.G)) PlaySound(Note.G);
if(Keyboard.PressedKey(Keys.H)) PlaySound(Note.A);
if(Keyboard.PressedKey(Keys.J)) PlaySound(Note.B);
if(Keyboard.PressedKey(Keys.K)) PlaySound(Note.C, 5);
}
private void PlaySound(Note note, int octave = 4)
{
NoteHistory.Add(note.ToString()[0]);
if(NoteHistory.Count > 40)
NoteHistory.RemoveAt(0);
var options = new WaveOptions()
{
Duration = 0.5f,
AttackDuration = 0.1f,
DecayDuration = 0.1f,
};
var sound = WaveType switch
{
WaveType.Square => WaveGenerator.Square(note, octave, options),
WaveType.Sawtooth => WaveGenerator.Sawtooth(note, octave, options),
WaveType.Triangle => WaveGenerator.Triangle(note, octave, options),
WaveType.Sine => WaveGenerator.Sine(note, octave, options),
_ => throw new UnreachableException()
};
Sounds.PlayWave(sound);
}
}
enum WaveType
{
Square,
Sawtooth,
Triangle,
Sine
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.14.0 | 92 | 6/14/2026 |
| 0.13.0 | 119 | 4/28/2026 |
| 0.12.0 | 113 | 4/16/2026 |
| 0.12.0-rc3 | 117 | 2/9/2026 |
| 0.11.0 | 152 | 1/9/2026 |
| 0.10.0 | 219 | 12/21/2025 |
| 0.9.0 | 345 | 11/13/2025 |
| 0.9.0-rc1 | 155 | 11/1/2025 |
| 0.8.0 | 278 | 6/2/2025 |
| 0.7.0 | 318 | 4/14/2025 |
| 0.6.0 | 279 | 8/17/2024 |
| 0.5.1 | 259 | 5/28/2024 |
| 0.5.0 | 267 | 5/24/2024 |
| 0.4.0 | 339 | 11/25/2023 |
| 0.3.0 | 242 | 9/17/2023 |
| 0.2.1 | 314 | 6/30/2023 |
| 0.2.0 | 332 | 4/16/2023 |
| 0.1.1 | 403 | 12/11/2022 |
| 0.1.0 | 366 | 12/11/2022 |