2021-02-13 05:33:17

This isn't the type of post that I normally make, but I'm getting started with c# and wanted to ask if anyone had any recommendations for libraries to use for AudioGames? Specifically I'm looking for a way to create a window where I can monitor keyboard input. I would appreciate any feedback, as I haven't dabbled much with the language before. I was initially looking at using forms, but most of the information I saw about keyboard input was for specific controls on the form instead of the form as a whole. (also I believe it's deprecated?))

Trying to free my mind before the end of the world.

Thumbs up

2021-02-13 05:56:24

There's MonoGame, which works okay. If you want ot handle everything yourself, you can also use SDL2 in C# -- not sure what its called off the top of my head though.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2021-02-13 07:20:08

i succesfully use windows forms to catch keyboard input. And a form inherits from control, so you can just subscribe to it's KeyUp, KeyDown events. This may be a bit unreliable, so you maybe will need to improvise like i did.

Discord: SkyLord#7437
Github
Twitter

Thumbs up

2021-02-13 08:35:33

When you say unreliable, what do you mean by this? What did you do to get around this issue?

Thumbs up

2021-02-13 08:44:33 (edited by SkyLord 2021-02-13 08:45:00)

I mean, that for example with the standard windows forms key events, you won't be able to capture wether right or left ctrl key was pressed, or left/right shift/alt. You have Control/Shift/AltKey, which correspond to both left and right keys, but if you will try to use LControlKey, for example, you will never catch it by this event. So if you want to actually distinguish left and right modifier keys, you will need to implement your own key press detecting thingy. And as an answer to what did you do question, i just implemented my own key press detecting system.

Discord: SkyLord#7437
Github
Twitter

Thumbs up

2021-02-13 11:06:36

I recommend you use either OpenTK or SFML.NET to handle windows and BASS for audio

“If you are not united,” Jamuka said in a low voice, “you can be broken by those of no importance, just like a single arrow. If you unite, you will be as solid as the five arrows and no person will break you.”

2021-02-13 11:24:28

OpenTK has its own audio thing, I believe it uses Open AL behind the scenes but I'e never used it.

“If you are not united,” Jamuka said in a low voice, “you can be broken by those of no importance, just like a single arrow. If you unite, you will be as solid as the five arrows and no person will break you.”

2021-02-13 17:52:32

My vote is MonoGame and BASS.

2021-02-13 18:29:22

Agree with  bass for audio. I used IrrKlang but eventually switched to bass.

Discord: SkyLord#7437
Github
Twitter

Thumbs up

2021-02-13 18:40:42

Is there anything even close to matching the sound pools out there for BGT / python for any of these sound libraries? Want to get into C# for audiogame development, but just getting sound to play nicely seems like such a minefield.

Thumbs up

2021-02-13 19:18:16

@10, pun intended?
And no, SPs won't work exactly the same, but BASS, OpenAl, etc all support full 3d Audio. There's no Synthizer binding for C# though yet, so I might write one.
You can also use the System.Media namespace and play mono wav files that way.

2021-02-13 19:37:34

you can port soundpool to bass just like i did and enjoy the exact same way of playing sounds like in bgt. At first i was scared of bass too, but eventually it turned out that it's really cool.
As @11 said, there's OpenAL and synthizer for 3d, taking bass out of this list cause it's 3d didn't work for me, though i did everything right. I mean, yeah, sounds get mono, doppler works, but there is no effect besides that.
@11, I have written bindings for synthizer to CSharp, and it worked, though i never tested them with the last version. I'll look at what you will come up with.

Discord: SkyLord#7437
Github
Twitter

Thumbs up

2021-02-15 00:51:16

I vote for monogame with synthizer, once I manage to find a binding generator that doesn't just drool spageti code on my folders, as swig is quite a piece of shit tbh.

Thumbs up

2021-02-15 01:39:50

@11, rofl rofl I completely forgot about that.
@12, have you considered releasing your dev tools? Just a sound pool and keyboard handling would be amazingly helpful for someone like me, or at least examples of how to properly do such manually in a game setting.

Thumbs up

2021-02-15 05:02:51 (edited by Ethin 2021-02-15 05:05:27)

I'm kinda confused on why we want sound pools and BGT idioms in every new programming language we adopt. Just learn how to use the libraries like everyone else. I hate to be a dick about it but this seems ridiculous. Okay, your used to it, but its ridiculous how BGT still affects us even now despite the fact that its been obsoleted for years. If you want to learn how to use FMOD/Bass/Synthizer/Wwise, learn how to use the audio libraries and use them directly. There's no need to severely abstract them away. At most, do a thin abstraction so that you have a place to store all your loaded assets, but other than that expose the raw API you'd normally work with.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up +1

2021-02-15 05:13:30

@14
Agreed. As someone who has spent a great amount of time branching away from BGt, so much of what I've learned has been about how things are actually done. I think it would be a lot more beneficial to stop bringing BGT habits into other languages and just learn the libraries as they are recommended to be used. (Not directed at anyone specific, just what I've learned and what has helped)

Trying to free my mind before the end of the world.

Thumbs up

2021-02-16 05:11:31

Is there something I'm missing when it comes to adding a reference to Tolk.dll in visual studio? Every time I seem to try, I get an error telling me that the reference is invalid/unsupported. Is the dll supposed to be somewhere specific inside of my project irectory? Is it not supposed to be inside the directory at all?

Trying to free my mind before the end of the world.

Thumbs up

2021-02-16 06:27:57

It should be in your bin directory. You don't add the C DLL to the repository but you build the .NET DLL and then you add that reference.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2021-02-16 08:13:00

Yuh, you want the reference to TolkDotNet.dll, not Tolk.dll. smile

2021-02-16 11:11:58

TOLK is kinda broken. I update my SharpSpeech wrapper for UniversalSpeech to support .NET5.

“If you are not united,” Jamuka said in a low voice, “you can be broken by those of no importance, just like a single arrow. If you unite, you will be as solid as the five arrows and no person will break you.”

2021-02-16 21:57:42

Hello,
So, regarding keyboard input, I'm extremely confused. I've looked at the winforms docs for the different keyboard events, but I can't find any examples for, you know, actually checking for a specific event from a specific key. E.G, if(key_pressed(KEY_SPACE)) //do something. Obviously that example was BGT, but I think you get the idea. Should I perhaps be using monogame instead?

Thumbs up

2021-02-16 22:18:50 (edited by Ethin 2021-02-16 22:25:12)

@21, your thinking in a more BGT-ish way of doing things. You need to get out of that mindset -- its not going to help you here.
Windows forms (and every other kind of UI library) rely on events to convey information to you. There is no central "key_pressed" function because that's not how a UI actually works. Even game frameworks like SDL2 and SFML do not function this way. I've no doubt that its safe to say that BGT has taught you the entirely wrong way of doing things. Which is why I keep emphasizing that we need to get rid of duplicating BGT idioms in other languages -- it breaks the underlying model of game design. A game fundamentally works off of events, not off of you constantly polling the system. Same for UIs and pretty much everything else. Asynchronous programming -- which is what this is -- is far better than endlessly polling the system for information. SDL2 and such may handle this asynchronous stuff for you so you can poll them as usual, but underneath this is what they're doing. In Winforms and such, though, you don't have SDL2/SFML to make your life all easy-peacy. And you shouldn't have them. Winforms and such is how GUI design works.
To handle keyboard events in windows forms, create a function to handle all keyboard events:

private void Form_KeyDown(Object sender, KeyEventArgs e) {
// Handle key down events here
switch (e.KeyCode) {
case Keys.A:
// Handle...
break;
// ...
}
}

You will also want to define keyboard events for key presses (the KeyPress event), key releases (the KeyUp event) and, optionally, the PreviewKeyDown/PreviewKeyUp events.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2021-02-16 22:19:41

Yes, if you write a game you should use a library for a game. Do not use a full-fledged GUI for a game. Use OpenTK or SFML or monogame. If you want a Winforms example anyway wait a while, I will provide it

“If you are not united,” Jamuka said in a low voice, “you can be broken by those of no importance, just like a single arrow. If you unite, you will be as solid as the five arrows and no person will break you.”

2021-02-16 22:25:59 (edited by Ethin 2021-02-16 22:27:27)

@23, I didn't say that. You can use a GUI library for games; Entombed does it perfectly fine and it does work. Its just not the best way because a non-immediate-mode GUI library wasn't intended for games. But you can certainly use them that way. Its just really, really hard to do and certainly not something I'd recommend. As you said, if your making a game, prefer SFML/SDL2/GLFW over a GUI library. I mean, you can use a GUI library to do it but... Then you're pretty much gonna fight the GUI the whole way.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2021-02-17 02:43:10

Yeah, that's pretty much the conclusion I'd already come to, was just curious if I had perhaps missed something obvious. I've worked with libraries such as pygame, tolk, etc in python before so I'm not all together unfamiliar with the process, I just wasn't quite sure how much of that was specific to python itself. Thank you.

Thumbs up