Resources for learning to deal with audio in .net? - c#

I'm not fully sure what I'm looking for so I was hoping to gain some insight. I'm brainstorming an application I want to write, but I've never dealt with this type of project. I was wondering if any of you knew of any resources, both literature and libraries/APIs that could lead me down the path to creating an application that involves the playback of audio, visualization of audio (like displaying the waveform with a scrolling position), setting playback points, maybe some effects like fade in and out, maybe even beat mapping; all in .net
For example, an application that displays a waveform and has a position indicator that moves with playback. It allows you to visually set multiple start and stop points, etc.
Any suggestions?

Check out http://naudio.codeplex.com/

Related

Monotouch C# play many sounds simultaneously with volume control

I'm making a War Game for iOS using Monotouch and C#. I'm running into some problem with the audio sound effects.
Here's what I require: The ability to play many sound effects simultaneously (possibly up to 10-20 at once) and the ability to adjust volume (for example, if the user zooms in on the battlefield the gun shot volume gets louder).
Here are my problems:
With AVAudioPlayer, I can adjust volume but I can only play 1 sound per thread. So if I want to play multiple sounds I have to have dozens and dozens of threads going just incase they overlap... This is a war game, picture 20 soldiers on the battlefield. Each soldier would have a "sound thread" to play gun fire sounds when they shoot because It is possible that every soldier could just happen to fire at the same exact time. I don't have a problem with making lots of threads, but my game already has dozens of threads running all the time and adding dozens more could get me into trouble... right? So I'd rather not go this road of adding dozens of more threads unless i have too...
With SystemSound, I can play as many sounds as I want in the same thread, but I can't adjust the volume.... So my work around here is, for every sound effect i have - save it like 4 times at 4 different volumes. That is a big pain... Any way to adjust volume with SystemSounds??
Both of these answer some of my requirements, but neither seems to be a seamless fit. Should I just go the AVAudioPlayer multi-threading nightmare road? Or the SystemSound multi-file-with-different-volume-levels nightmare road? Or is there a better way to do this?
Thanks in advance.
Finally found the solution to my problem. AVAudioPlayer IS capable of playiing multiple sounds at once but only with certain file formats... The details are available in this link. The reason why I couldn't play my sound effects simultaneously was because the file format was compressed and the iphone only has 1 hardware decompressor.
http://brainwashinc.wordpress.com/2009/08/14/iphone-playing-2-sounds-at-once/

Overlay the word/number in the Windows game fullscreen (like in Fraps)

I think a lot of people used application "Fraps" for recording video from game. I use it for displaying FPS (frames per second) in the games. Fraps can show digits at the corner of screen when game runs.
I want to display core temperature of processor. The temperature I will find, but I need to khow, how can I display it in the game? (I need it for testing core temperatures in the game, because stress tests of Everest/AIDA64 doesn't much load the system).
Want to use C# (but can listen to all solutions, C++, Java)
Example games: Dirt2, Call of Duty 5 (DirectX)
P.S. This post was similar...
c# text/winForm overlay video games like xfire,PIX,steam,fraps etc
What you want to do is a bit more complex than you might think. There are different sources on the web about this, some might be a bit outdated. A good search Term is "Hook direct 3d", there are also other threads on stackoverflow about this topic. A good thread is also this.
One advice: You are changing the runtime code of the game, which can be detected by anti cheat mechanism and can cause banning if the game is a multiplayer game. It is even possible that widely known applications like fraps are on some sort of whitelist against these checks, but i'm not sure about that.
An alternative to what you want could be to make your form always stay on top (form.TopMost = true;). Then you can set the transparency color the same color as your form (by default it would be form.TransparencyKey = System.Drawing.SystemColors.Control;). After that you can remove the border of your form (form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;).
Be careful not to use the transparency color anywhere else (it'll make part of images transparent if it contains this color).
Make sure to have a way of closing the form. (and moving it if needed).

How to detect change on the screen?

I have a question that How to detect the change on the screen? Its position is not necessary but is possible to get its position it will be helpful. I searched it on the internet but not found any suitable answer. Now, I am making a program in C# and I have to detect a change on the screen. I tried to capture four screen shots per second and compare them. This method works but it badly effect on the performance of the PC.
I think it is easy to do in C or Assembly language (x86) because in assembly we can get access to video memory directly.
Is it possible to do in C#?
Code sample will be appreciated.
Project: Detect any change on full Screen camera monitoring software.
Are you really looking just for simple difference of what you see on your monitor? I doubt that would do the job.
For motion detection from cam input you can take a look at Motion Detection Algorithms article on CodeProject.
Aside from taking screen captures and comparing them at some time intervals (which would cause performance issues),
The only solution i can think of is hooking up to system events, the "redraw" kind of events.
You will need to choose which events to hook your program with.
This codeproject tutorial might help-
http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx

C# WinForms application to display waveforms of playback and recorded sound

I wish to write a C# WinForms application that can play a WAV file. While playing the file, it shows a waveform (similar to an oscilloscope).
At the same time, a user can record sound via the microphone, attempting to follow the original sound played (like a karaoke). The program displays the waveform of the recorded sound real-time, so comparisons can be seen from the waveform display of the original
wave file and the recorded one by the user. The comparisons will be done as in the difference in time (the delay) of the original and recorded sound. The waveform displays don't have to be very advanced (there is no need for cut, copy or paste); just being able to see it with a timeline would suffice.
I hope this is clear enough. Please do not hesitate to ask for more clarification if it's not clear. Thank you very much.
You can do what you want with C#, but it isn't going to work like you think. There is effectively no relationship at all between how a recording looks in an oscilloscope-type display and how that recording sounds to a human ear. So, for example, if I showed you two WAV files displayed in an oscilloscope display and told you that one recording was of a tuba playing and the other was of a person speaking a sentence, you would have no idea which was which just from looking at them.
If you want to compare a user's sounds to a pre-recorded WAV, you have to get more sophisticated and do FFT analysis of both and compare the frequency spectra, but even that won't really work for what you're trying to do.
Update: after some thought, I don't think I fully agree with my above statements. What you want to do might sort of work if what you want to do is to use the oscilloscope-type effect to compare the pitch (or frequency) of the WAV and the person's voice. If you tuned the oscilloscope to show a relatively small number of wavelengths at a time (like 20, maybe), the user would be able to quickly see the effect of raising or lowering the pitch of their voice.
I have a small sample C# app that I wrote about 2 years ago that does something kind of like this, only it displays an FFT-produced spectrograph instead of an oscilloscope (the difference is basically that a spectrograph shows frequency-domain information while an oscilloscope shows time-domain information). It's realtime, so you can talk/sing/whatever into a microphone and watch the spectrograph change dynamically.
I can dig this out and post the code here if you like. Or if you want the fun of doing it all yourself, I can post some links to the code resources you'd need.
The NAudio library has plenty of functionality that will (possibly) give you what you need. I've used it in the past for some simple operations, but it is much more powerful than I've had need to use.
#ZombieSheep
Naudio is indeed useful, but it has limitations. For example, there is not much control over the waveform display, it cannot be cleared and redrawn again. Besides, if it gets too long its impossible to scroll back to see the waveform in the front part. One more thing is that it only works with playing the sound but does not work with recording the sound.
Thank you.

Xact vs AudioContent

I am using XNA to develop a game which requires both sound effects and music. I'm trying to figure out how to implement the sound engine. Microsoft provides the ability to use the Content Pipeline to load and play audio. However, I also seen people use Xact to do the same thing. My question is, whats the difference and what would be the better approach to making a sound engine?
Xact is feature rich but complex to use. It was originally the only way to play sound but people wanted something simpler so Microsoft added the content pipeline method.
Use the Content Pipeline if you want:
To play a sound (2d or 3d)
To not have to invest a lot of time
learning an audio framework
Use Xact if you want:
Categories of sounds that can be
interdependently controlled, like
mute game sounds but not menu sounds
Real time advanced control over sound
pitch, volume. For things like
turrets spinning up, cars
accelerating etc.
To have multiple varieties of a
single sound effect like a seven
different pain sounds and have Xact
choose which one to play.
To have a sound play with slightly
different pitch, volume, filter or 3d
pan every time it is played. This is
really good for bullets and
repetitive things like that. There
is nothing that says fake computer
simulation like a repeating sound
with no variance.
To allow a game designer or sound
designer full control to edit and
change sounds without touching the
code.
To have sound banks (collections of
sound) that you can load or unload as
a group, which can use different
compression settings and can be in
memory or streaming.
To mix the volume, pitch and priority
of sounds in an editor.
To apply filtering to a sound.
To control whether the sound is
looping or not.
To use DSP Effects
One of my favourite things about Xact is editing and previewing of sound functions in editor. For example a volume fade on a turret overheat sound. With XACT you can sit down with the sound designer, even if he's not a technical guy and edit the control curves until he's happy with the sound. Once you've set it up it's really easy to change later on. In this example image here a turret is overheated. At the end of the overheat cycle the hissing steam noise volume is reduced, but because it's a curve I have a lot of control over how the sound fades out. I've used this with a beam weapon as well, dropping the frequency according to a curve as it runs out of ammo.

Categories

Resources