Using u-law compression for audio files on Windows 7 - c

I need to convert some hi res audio files to u-law compression. I find no documentation on this- I'm almost certain the codec is there on Windows machines, but how the heck do I access it?

Yes the codec is there, however it is outside of WASAPI. APIs that deal with codecs are:
Audio Compression Manager
DirectShow
Media Foundation
Not sure about the latter, however the first two have the μ-law encoder readily available (the codec itself has ACM interface, and DirectShow offers a wrapper over it).

Related

JPEG Load/Save to/from rgba via Win32 API in C via grid32

I want to be able to load/save jpeg files on Windows via api, specifically gdi32.dll because it looks to universally exist in all versions of Windows.
But I'm unable to find any information on how to do this from an array of pixels with 4 bytes per color (rgba, bgra, rgb would be ok to since jpeg doesn't support alpha etc.)
Not interested in an external library or gdi+. gdi32 should have the ability, but I can't seem to find enough information on how to implement it.
I am going to ignore your refusal to use anything outside of gdi32.dll, because that kind of requirement is not likely to help anyone, and as #David Heffernan said, there is no JPEG support in gdi32.dll.
There are a number of ways to load/save JPEG pictures built into winapi, and supported all the way back to Windows 2000 (and earlier...).
OleLoadPicture / OleSavePicture - though I am not sure if it's very easy to save your own JPEG files this way.
Gdiplus::Image allows loading & saving JPEG files.
Plain GDI does not have any support for JPEG.
If you won't countenance using a library other than GDI, then you will have to write your own JPEG library. Allow me to recommend that you reconsider your requirements.
The GDI is the Graphical Device Interface. It's responsibility includes rendering primitives to the screen or offscreen device contexts. Encoders and decoders are not included.
The standard Windows encoders and decoders are provided through the Windows Imaging Component. This component is available starting with Windows XP SP2. It is also available for Windows Store apps.

Silverlight 4 Audio Compression

Any suggestions on how to implement Compression of captured Audio in a Silverlight 4 Application? I'd prefer something lossy like MP3 or AAC but after my intial research only turned out one lonely pure C# FLAC encoder/decoder, anything better than this would be nice.
Please note that sending uncompressed audio to the server and compress it there is not an option because of a) traffic cost and b) the audio is additionally encrypted by the client so the server never sees the source material.
I don't know of any implementations of proprietary compression algorithms in C#. You pretty much would have to implement your own. ADPCM is silmple and offers 4:1 compression ratio. More on the subject: http://forums.silverlight.net/forums/p/145729/374278.aspx
Does it have to be C#? LAME is a pretty good, very configurable MP3 encoding library.
http://lame.sourceforge.net/

How do I encode video in Visual C?

I have a video decrypter library that can decode an obsolete video format, and returns video frames in BMP and audio in WAV through callback functions. Now I need to encode a new video in any standard format under windows.
What might be the standard way to do this? I am using Win32/C. I guess Windows has its own encoding library and drivers and I don’t need to use FFMPEG. Any pointer to an example code or at least to a library to look at will be greatly helpful.
Edit: I accept. FFMPEG is the easiest way to do it.
On Windows, you have two native choices.
The old Windows Multimedia library which is too ancient to seriously consider, but does have the Video Compression Manager.
And then there's DirectShow.
It's certainly doable through DirectShow, but you better enjoy COM programming and the concepts of Filters, Graphs, and Monikers (oh my). See this tutorial for a crash course:
Recompressing an AVI File
And the MSDN documentation.
A simpler approach is indeed to use an library like FFMPEG or VLC.
To save yourself heartache, I echo Frank's suggestion of just using FFMPEG. Executing a separate FFMPEG process with the correct arguments will 100% be the easiest way to achieve your goals of encoding.
Your other options include:
libavcodec - The central library used in FFMPEG. I warn there don't appear to be many Windows binaries of libavcodec available, so you'd probably have to compile your own, which, at minimum, would require a Cygwin or MingW set up.
ffdshow-tryouts - A video codec library implemented as a DirectShow filter based on libavcodec. They do seem to have an API for manipulating it, but it's a .NET library.
I would suggest looking at the VirtualDub source code. It's a well known encoder that uses VFW. You may be able to get some ideas from that software.

How do I play an ogg vorbis file in Silverlight?

I'd like to play back ogg vorbis audio from http in Silverlight. What do I need to make this happen?
A better answer than "Silverlight doesn't support Ogg Vorbis" is to say that Silverlight doesn't support playing them natively. As one of the other commenters pointed out, a way to play them is described at http://veritas-vos-liberabit.com/monogatari/2009/03/moonvorbis.html, with the current source for CSVorbis available at https://github.com/mono/csvorbis. You would indeed need to implement a MediaStreamSource to play the resulting PCM stream, but that's not rocket science.
Silverlight does not support playing ogg vorbis files.
If you'd like Silverlight to play files already encoded in ogg vorbis, I suggest converting them. Either do a one time sweeping convert of all your files, or convert them on the fly while your server is serving them.
Alternatively, In Silverlight 4, assuming you know enough about Media Formats and Ogg vorbis is particular, you can implement MediaStreamSource to support ogg vorbis.
http://msdn.microsoft.com/en-us/library/system.windows.media.mediastreamsource(VS.96).aspx

Best API for low-level audio in Windows?

I'm working on an audio application, written in C. I need to provide live audio playback under Windows. I need to decide which audio API to use. I'm planning to use the basic waveOut API, but I wanted to check to see what the community here recommends.
I want code that will Just Work on any recent version of Windows, with no need to install libraries; and I want minimal latency.
I don't need or want any "effects", I just need to faithfully play whatever wave samples the application generates.
My understanding is that most of the professional audio applications on Windows use ASIO, which gives excellent low latency, but I don't want ASIO because I want my code to Just Work and most people don't have ASIO pre-installed on their computers. (At a later date I may go back and also add ASIO as an option, but I'm going for the most general solution first.)
Is there anything out there that would be better than waveOut for my purposes, or is that the best choice?
It depends on what you are trying to do. The basic waveOut audio API is better for streaming audio. It lets you queue up several buffers and have them automatically played in succession. But if audio is playing and you want to change it, or add something to it, that's relatively hard.
DirectX audio is better for event based audio. You can have several things playing at the same time without having to do the mixing yourself. You can add or remove little pieces of audio easily - like playing a sound when the user pulls the trigger on their gun. But streaming (i.e. playing 1 buffer after another) is harder.
waveOut is designed to facilitate playing audio that is constant, like a .mp3 file. DirectX is designed for audio that is intermittent, like feedback in a game.
ASIO is like the worst of waveOut and DirectX in terms of difficulty of programming, and it's not that stable. Applications typically can't share the audio device. However, it gives you the lowest latency access to that audio hardware. ASIO also gives you a way to synchronize playback on multiple devices.
If you don't need to be able to change what is going to be played right before it is played, and you don't need to synchronize multiple devices, then you don't need ASIO.
in addition to the options mentioned by John Knoeller, there is WASAPI which allows for much lower latencies than WaveOut, but unfortunately is only available from Windows Vista onwards.
At the time I asked this question, I wrote streaming code using the waveOut and waveIn APIs. Since then, I have discovered a useful library:
PortAudio
http://www.portaudio.com/
PortAudio is free software with a commercial-friendly license. If you write your code to call PortAudio it should be able to work with waveOut devices but also with ASIO devices under Windows; it can be then recompiled for Linux and should work with ALSA devices; and it can then be recompiled for the Mac and should work with CoreAudio devices. I haven't tested the Mac part but my project is working great with Windows and Linux.
Having written a DirectSound streaming application myself, I certainly recommend it for low-latency and ease of use. Also, it enables you to set a higher quality format for playback on legacy editions of Windows.

Resources