encoding mp3 or other music files - c#

a bit of background:
this summer, i set myself a programming project,
where i want to make an E-jay clone(a program with simple drag-drop blocks which are little bits of music and beat to make a track)
now i dont really know where to start on the whole encoding music bit.
for example:
how does a sound file work?
how do i transform a piece of a sound file into a universal piece of sound information
how do i create a sound file from scratch
how do i add pieces of sound to a previously newly created sound file
im sorry if i seem like one of those guys that cant use google n stuff. but i have no experience with sound or anything on that part.
programming language: C#
ultimate goal: be able to encode a new mp3 file using small sound files which are inserted on certain points in the file to ultimatly make music
any help is appreciated,
thank you for reading my question.

I think you should check NAudio site - it has lots of examples.

Do some research into the MPEG compression standard, as you'll need to know about decoding as well as encoding. If you are going to be ambitious, maybe look into other audio file types as well.
MP3 Links:
MP3 Format
ISO Draft on the MPEG standard

Related

Playing sound file from a live audio feed

I am looking to make a sound visualizer with Unity3D (mainly for the UI and graphics), and as I get ready to export the project, I need to know how to get a live audio feed from whatever is playing on the computer and translate that to the audio samples that my program uses.
Currently, I use preset .mp3 files and apply them to audiosources, and a script updates the samples live and those translate to the bars you see in audio visualizers. I would like to move this up a step, but I don't know how to do that. I've looked into NAudio and CSCore, but I haven't been able to make anything work.
All I need is for NAudio or CSCore to record to a file, and also have me continuously play that file. That seems like it would have problems though, so if I can just get a sound card stream and use that data to pass through to the program, that would be great.
If anyone has any experience, docs, or tips that can help me out, please send them over. Appreciate the help, thank you.

How can I save a webcam-recorded mp4 with audio in Visual C#?

I'm two days into researching this so I thought I'd post here. It looks like video recording software is usually written in C++ but my project requires C#. It's a WPF application and I just need it to save an mp4 locally. I don't need to upload to a server, I don't need to let the user pick a file location, I don't even need it to display the webcam feed as it's recording. All I need it to do is start/stop recording audio and video from a webcam/microphone and save it in a location that's determined by the code. I understand this may be broken down into steps like connecting to a webcam, connecting to a microphone, synchronizing them, encoding a video file, and saving it on the hard drive.
Are there any .NET classes that can help me with this? If not, can anyone recommend some libraries/frameworks/etc. that handle this sort of thing? I appreciate any help regarding how to do this. Thank you.

How to get sound portion of an MP4 (video file)?

I am developing a windows phone 7 application and it does video recording. I would like to get the sound portion of the video file (MP4) and do some enhancements on the sound. I believe sound is saved as AAC frames in MP4. (Right?) How can I extract sound of a videa MP4 file?
Since this is a video file, it can be huge file. So uploading to cloud and processing there is not a good option. Since this WP7 application I cannot use unmaged dlls :( Is there a way to do in pure C#? Any open source tools/samples?
Thanks!
MP4 is a container format and realistically the sound portion isn't always AAC. It could be MP3 or any other number of different audio formats. You may be thinking of M4A, which I believe requires either AAC or ALAC.
On the subject of audio extraction, it should be possible to extract the audio from an MP4 using just managed code. You'll have to read up on the MP4 format (here, for example - this question is also worth reading) and then search through the file for the location of the audio and then either copy it to its own buffer or do your manipulations in chunks. Even then, you'll have to be able to recognize when it isn't an audio format that your app won't support.
It's possible that there already exists a .net library that can do all of this but I don't know of any. It's probably not very popular because managed code is definitely not the best angle to approach this from, but considering this is Windows Phone, it is, as you noted, your only avenue of approach.
Good luck!

Using Sound files C# - modifying tempo

Does anyone have any idea how to modify the sound speed and play a sound file faster/slower than the original in C#?
At the moment I am using .wav files, I have searched a lot and found that SoundPlayer and AudioVideoPlayback are the only two options to play sound, but none of them contain any special method to increase or decrease the sound speed with which to play with.
I am building a piano application which lets user modify the tempo, this is the situation I am in at the moment. I hope a few musical programmers can help me! Cheers
A similar question was asked earlier:
C# Audio Library
One of the answers there suggested the following tool which might be helpful to you:
http://naudio.codeplex.com/
What you are looking for is a time-stretch audio library, which changes the playback speed but not the pitch -- with almost no artefacts.
A few excellent timestretch libraries available:
dirac: http://www.dspdimension.com/ (best)
rubberband: http://breakfastquay.com/rubberband/

C# manipulating video

i want to take a folder of pictures, and turn it into a slideshow video with music in the background.
i have no idea how to do this, or where to get help, cos this isnt the kind of thing you can search in google.
idk if there are api's for it, or if it can even be done in C#.
maybe ill have to move the project to C++ or something, but first i need to know where the hell to start.
thanks.
This is definitely the kind of thing you can search in Google. Try "creating avi files in C#" and pick one of the answers. I recommend this one from personal experience.
Creating an AVI file is actually pretty easy - you basically just set a frame rate and dump in a bunch of bitmap files, then add a WAV or MP3 file (or files) for the audio, and that's it.
The AVI file can then be played as is, or compressed into an MPEG or whatever (although you won't get much size compression with a slideshow-type video file, you also don't need it as much).

Categories