I am currently working on an application Dj for windows 8 metro app . And I would like to know how to allow changing the frequency of a "MediaElement"? The only property to change / vary the parameters are the position / volume / balance. But I wish I could change the frequency in Hertz for example, or to manually set the canal. thank you very much
MediaElement.PlaybackRate seems to control playback speed, but not necessarily by affecting frequencies. I believe I have read somewhere that its behavior might depend on specific codec or system and it is most likely not good enough for a Dj application.
I have not tested all these options, but I think alternatives to try are Media Foundation, XAudio2 or WASAPI, though these options are also progressively more complicated.
Related
If I have a video file that defines a video image that is 6144 pixels long (x) by 64 pixels high (y) and I want to display that video so that it wraps at the end of the monitor. In other words I want to display the first 1024 pixels of the video starting at position 0,0 on the monitor, then video pixels 1024 to 2047 starting at position 0,64, and repeat this until all 6144 pixels are shown on the monitor. That would mean the video needs to wrap around on a 1024x768 monitor 6 times.
What is the best way to do this? Can DirectX, DirectShow, Media Foundation, or Windows Media Player ActiveX Control handle this wrapping for you automatically? I need to do this preferably in C#, but not opposed to dropping in to C++ native. Or is the only way to do this, is to split the video into 6 separate sections and play them in separate window? If splitting them into 6 separate videos and playing them in 6 separate windows is the only reasonable way, how do you make certain they start at the same time so they are sync'd?
Just thinking about something per comment below could ffmpeg and/or C# transform this 6144 x 64 pixel video file into something like this:
6144 x 64 ---> 0-1023 x 64
1024-2047 x 64
2048-3071 x 64
3072-4095 x 64
4096-5119 x 64
5120-6143 x 64
In other words what looks like it's wrapped but really just one video that's 1024 x 384 ??
You need to develop a transformation which converts your 6144x64 video to resolution in question (1024x768 or different) and integrate it with one of the player pipelines. When you convert the video frames to required resolution, the frames can be presented as usual video playback, esp. fullscreen in you need to span in across the entire monitor, and such playback on its presentation end will not differ from play back a regular video file meaning that you can use standard components and APIs.
All video APIs are native: in most, if not all, cases you would be better off implementing the transformation in C++ rather than C#.
With DirectShow you typically develop a transform filter which accept the video frames and rearranges the pixel data respectively to your requirements. With Media Foundation the similar task is achieved by developing a Media Foundation Transform (with the data processing in CPU or GPU domain). In both cases you are packing your transformation step into API defined form factor and extending the standard pipeline.
Otherwise you can also prepare the frames outside of the playback pipelines and inject them already prepared. Even though possible, it is perhaps a more complicated way but it can be preferred by those who are not well familiar with the mentioned APIs.
When you prepare a re-arranged frame for presentation at once you don't need to do additional presentation synchronization. Presumably, this is the way to achieve the mentioned task as the splitting into parts and managing synchronized presentation is a more complicated for now reason alternative.
DirectShow vs. Media Foundation - both APIs let you play video with the same quality and performance (exception might be that you need GPU only processing, in which case Media Foundation might be a better choice, but in your case it's unlikely that you can leverage this advantage).
DirectShow is older and near stop of its development but offers much more online tutorials, discussions, materials, helpers and samples. Windows SDK 7.1 EzRGB24 Filter Sample is a good start point for a transform filter.
Media Foundation is newer and "current" API, presumably a more reasonable choice. Windows SDK 7.1 offers MFT_Grayscale Sample for a starting development point. It is generally possible to implement a C# MFT for Media Foundation (there are good reasons to not do it - 1, 2). Even though DirectShow is notorious for being an API with a step learning curve, for the video effect developer Media Foundation is even a more complicated API.
Generally speaking the API choice should take into consideration, if not even be defined by, your preference for playback pipeline.
Up until now I thought that changing the system volume from your app is impossible, until recently a new app called Quite Hours (http://www.windowsphone.com/en-us/store/app/quiet-hours/f347a36b-80c0-430f-8631-e55046ee5a2a) actually did just that in a very neat way.
Does anyone please know how to do that programmatically? I tried using the MediaElement or the xna MediaPlayer and the backgroundAudioPlayer and nothing worked. Any help would be appreciated!
Thank you!
The developers of the apps mentioned in the OP were able to change system volume under WP8.0. Apparently whatever method they used has now been disabled under WP8.1. The following apps now display disclaimers that they no longer work on Windows Phone 8.1: Quiet Hours and Volume Manager
They direct to the following page to vote to allow this functionality: Windows Phone Dev User Voice
Additionally please read the following thread on the MSDN forum: MSDN change system volume Windows Phone 8. This functionality was likely achieved using WASAPI (which I have personally tried, and failed, it does not work, comment if you want my code to try it.), or the developers of the volume apps might have had access to AudioClientRestricted.h. If one had that h file, one would have access to system volume under WP8.1, so I somehow doubt the developers used the h file designated for OEMs because it would work un 8.1.
Talking with James Dailey (who works # MSFT) indicates it is technically possible using WASAPI ISimpleAudioVolume If you read # the bottom of that page there is a comment indicating you must use IAudioEndpointVolume
Added note from James Dailey # MSFT:
AFAIK there is no good way to manipulate the global audio level on
Windows Phone 8.1 (WP8.1). Theoretically you can change the audio
volume of any app that uses the default audio session “zero”. However,
if the app chooses to initialize it’s audio session with a custom
GUID you will not have access to the session volume for its custom
audio session. Again this is theoretical based on my knowledge of the
inner workings of WASAPI. I’ve never actually tried it on the phone.
To manipulate the audio volume of apps using audio session “zero” you
simply initialize your IAudioClient with an AudioSessionGuid parameter
of “{00000000-0000-0000-0000-000000000000}”. You can then use
ISimpleAudioVolume::SetMasterVolume to set the volume for this audio
session. You will need to use C++ / Cx since we do not support
calling WASAPI from managed code.
There currently is no API available for controlling the system volume. You can however control the volume in the elements of your application (via the classes MediaElement, BackgroundAudioAgent).
You can also control the volume on sound effects of your application using XNA API.
See http://msdn.microsoft.com/en-us/library/bb195052%28v=xnagamestudio.30%29.aspx
I'd like to embed a simple WAV player into my Winforms program. It could look like this (derived from Media Player Classic):
I'd like the following 'features':
Controlling the slider of the sound/music shouldn't hog the other GUI's input (perhaps a background worker would help here)
The input will be WAVE for my requirements
There should be play/stop/pause buttons
The sound should play from a byte[] array in RAM (i.e. the WAV), and preferably not from a file
Granularity of slider should be fine (i.e. not like Youtube's coarse 'to-nearest-10-seconds' style)
Lightweight size (preferably already included in .NET if possible)
Low latency playing/stopping of sound (i.e. not waiting half a second after pressing the button)
After a little research, I found this low-level sound generation question and also something called NAudio. However, the former doesn't easily supply 'stop' functionality and has no slider code supplied. And the latter is a bit overkill (includes display of the WAV and many other features).
There's also the Windows Media Player control, but that's also a bit overkill (includes video etc.), and you apparently need to make sure that the required Windows Media Player version is installed on the user's computer, so compatibility may be an issue.
Anything, simple fast and effective here?
I've seen speech recognition from input devices (obviously) and I've seen speech recognition from files (http://gotspeech.net/forums/thread/6835.aspx). However, I was wondering whether it would be possible to run speech recognition on system audio in real time. By system audio, the sound that comes out of your speakers.
It would be a great tool for those who are hard of hearing, as they are watching YouTube videos, the C# Application could transcribe what's being said.
How could I go about doing this?
Very easily - Go to the sound mixer, choose input and enable/unmute "Stereo Mix". You should, of course, mute the mic if you don't want to record that too. Then, just start recording the same way you'd record the mic - now you'll get the same feed as the speakers at digital quality.
This can be done programatically although it can be fiddly - especially if you want to support WinXP as well as Vista/Win7 (Sound was overhauled in Vista and I believe the APIs are significantly different although I haven't had to use them yet).
You're almost certainly going to need to filter the sound before attempting recognition. Unless the speech recog. library you're using is designed to work in adverse conditions, music and special effects will interfere with proper recognition as will multiple people speaking at the same time.
If you haven't got a super-robust library, filters to attenuate non-vocal frequencies are going to be a must. You may also need to apply volume normalisation to account for loud/quiet scenes - There are hundreds of filters that could potentially improve matching.
You may want to access the recognition API at the lowest level to get as much control as possible - You'll need to tweak it to cope with people shouting, breathless, crying, etc... If you start designing for flexible low-level access, it will probably save you weeks if you find you need it later on and have to re-architect.
I'd suggest you look into NAudio as a starting point for audio processing
I suspect you'll be able to get something which works under ideal conditions without too much effort - but tweaking it to work well in all eventualities may be a mammoth task. That said, it sounds like a fun project.
You could improve recognition chance considerably by creating genre-, user- or show-specific dictionaries. These could either be pre-generated, or built automatically using a weighted feedback loop - perhaps also allowing the user to correct mistakes.
I'm developing an application that uses a Logitech Webcam Pro 9000 (and no other) to capture and filter a stream. I've used AForge.net and gotten a quick start. I've already managed to get the webcam stream and apply a filter to each individual image.
However I want to use the webcam in specific environments. To help the user, I want to create controls in the application that allow the user to change the webcam's gain and exposure time (I know the last one appears to be more tricky than the first).
I've been looking into DirectShow.Net, but I don't grasp that quite yet. Is this a feasable solution? If yes, are there good examples/tutorials?
The final goal (regardless of libraries):
How can I make a control that changes the gain (and exposure) on the Logitech Webcam Pro 9000 and turn of any automatic adjustments?
Setting exposure works fine with DiredtShow.Net, but there is one catch!
You will have to set the exposure only AFTER you started the capturing graph. For some reason, it doesn't work other way.