Pages

Sunday, December 30, 2012

Detect CPU architecture at runtime for Windows 8 Store Apps

  If you are developing an application for the Windows 8 Store it is very important that you test it on an ARM device (Surface RT, Asus VivoTab RT, Dell XPS 10,etc.) before sending it into certification. You will probably have some bad surprises and not everything that was fast&fluid on your development machine will continue to be so on an ARM device (the list scroll performance reminds me of the first version of Windows Phone). So you will have to simplify the layouts, animations and in some cases even rewrite part of your code. Parallel Programming is your friend if you can use it (for Kids' Orchestra I had the big problem that generating 100ms of sound output took more then 100ms so after 2 days of trying to optimize the C# source code I realized that I only had to use the Parallel.For and everything started working). 
   Due to performance differences you might need to split the user experience/code on different architectures (like disabling some animations on ARM). If this is the case it becomes very important to know the processor architecture on which your application runs. One solution would be to create 3 different packages of your applications and use the conditional compilation to differentiate between what happens on each architecture. If you still want to use only one package (Any CPU) it is enough to have a method that returns the processor architecture.
    The bad news is that WinRT framework doesn't have any method/property that returns the processor architecture  (at least I don't know it). The good news is that you can still use GetNativeSystemInfo as it is an api supported for Windows Store apps (it is even supported for Windows Phone 8 apps):


  For Windows Store apps you can use two approaches to call this api:
1. Use P/Invoke -this is the one I opted for;
2. Create a Windows Runtime Component in C++ that you can then call from managed code - this is the approach you will have to use if you need to call this function on Windows Phone 8.

   What I did is to create a public class, which I called CPU, and has one public static property NativeInfo that returns an SystemInfo object:

 public class SystemInfo  
{
public ProcessorArchitecture ProcessorArchitecture;
public ushort ProcessorArchitectureId;
public ProcessorType ProcessorType;
public uint ProcessorTypeId;
public uint NumberOfProcessors;
public ushort ProcessorLevel;
public ushort ProcessorRevision;
public uint AllocationGranularity;
};

and a public method IsProcessorFeaturePresent (invoking also a supported Api for Windows Store applications) which returns if a certain ProcessorFeature feature is supported or not.

I have also created a small sample that will give you a list with your processor details. Here is the result I got on  my Surface:


Hope you will find the class useful. Don't hesitate to contact me if you need further details.

SOURCE CODE:

NAMASTE!

Wednesday, December 26, 2012

C# XAudio2 Sound Playback for Windows Phone

     Let's begin with a small introduction to XAudio2:
     XAudio2 is a low-level audio API. It provides a signal processing and mixing foundation for games that is similar to its predecessors, DirectSound and XAudio. XAudio2 is the replacement for both DirectSound and XAudio.
     XAudio2 abstracts audio generation by separating sound data from "voice", allowing each voice to be filtered by programmable digital signal processing and effects processing functions. Voices can be "submixed" together into a single stream. There is always only one Mastering Voice that outputs the result using WASAPI.

     XAudio2 is primarily intended for developing high performance audio engines for games. For game developers who want to add sound effects and background music to their modern games, XAudio2 offers an audio graph and mixing engine with low-latency and support for dynamic buffers, synchronous sample-accurate playback, and implicit source rate conversion. Compared to WASAPI, XAudio2 requires only a minimum amount of code even for complex audio solutions. Compared to the Media Foundation engine, XAudio2 is a low-level, low-latency C++ API that is designed for use in games.
     XAudio2 cannot be used for background music - for this task you will have to use the IMFMediaEngine. XAudio2 cannot be used for capturing audio - for this task you will have to use WASAPI. Do not use XAudio2 for media playback. For that task you can use MediaElement
    XAudio2 is part of the DirectX api that is included in the new Windows Phone 8 SDK. The Api is shared between Windows 8 and Windows Phone 8 which means that you will be able to fully reuse your source code on both platforms. 

If you want to use XAudio2 for your C#/VB/HTML code you have two options:
1. Use SharpDX . SharpDX is a wrapper of the DirectX Api under .Net platform. Theoretically you can use it to call XAudio2 api directly from your managed code. Practically what happens is that the .Net CLR/GC on ARM seem to block native threads so your audio will shutter/glitch in certain conditions. I had the same problem when I was developing our Windows 8 game Kids' Orchestra and the audio had glitches even on a core i7 processor.
2. The other option, which from my experience works better, is to develop an Windows Phone Runtime Component that will manage the XAudio2 part and expose the needed methods/events to the managed code.

      To better understand how it is done I took the Windows 8 sample XAudio2 audio file playback sample C++ from MSDN and ported to Windows Phone 8 by splitting it in two projects: The C#/Xaml part for the UI and the "audio" project which is a Windows Phone Runtime component developed in C++.
     The porting was pretty easy. I only had to re-code the player class to make it "visible" to the managed code project and added an event that will tell you when a certain Source Voice has finished playing its buffer/sound (we have 7 sounds and each sound has a Source Voice associated to it). If you need further details on how to write a Windows Phone Runtime component in C++ have a look at this  MSDN Post

    This sample only plays Wav files that are resources in the C++ project. You could also dynamically generate sounds in managed code and pass the Wave/buffer data as a byte[] to the runtime component. Inside the native code you will then generate an XAUDIO2_BUFFER and submit it to a Source Voice for playing.

     I have attached the SOURCE CODE for the Windows Phone project. If you have problems with it don't hesitate to contact me.

NAMASTE!

Friday, December 21, 2012

Unable to use Windows Phone 8 Emulator without SLAT support

After installing the Windows Phone 8 SDK I got an error stating that hardware virtualization was not supported on my machine therefore I could not use the emulator.

Apparently there are two requirements for your machine to meet to support the Windows Phone 8 emulator:

  • Support for hardware virtualization in the form of either Intel-Virtualization Technology (Intel-VT) or AMD-V (also called SVM)
  • Support for Second Level Address Translation (SLAT) – see How to Check if your CPU supports SLAT – on Intel CPUs this is also called Extended Pages Tables.

This is caused by the fact that the Windows Phone 8 Emulator is using the client version of Hyper-V (which ships with Windows 8 client OS) which requires SLAT. The Hyper-V server does not.

Because I don’t have a Windows Phone 8 device on hand – I’m pretty much stuck building Windows Phone 7.1 apps.

Technorati Tags: ,,,

Thursday, December 20, 2012

First sessions announced for TechDays 2013 Belgium - early bird discount available

TechDays 2013 will take place on 5,6 and 7 March at Kinepolis Antwerp – the agenda is slowly filling up. For SharePoint developers there is an interesting pre-conference deep dive track with sessions by Dan Holme, Serge Luca and Lieven Iliano.

SharePoint sessions:

During the main conference no SharePoint sessions seem to be scheduled which is quite strange because the goal of the new SharePoint app model was to open up SharePoint to the average .NET developer.

Tags van Technorati: ,,

Wednesday, December 19, 2012

Μεταφορα αρχειων με BlueTooth ..Επιτελους !!!

 



Ολοι οι χρηστες WP με την ανακοινωση των WP8 σκεφτηκαμε οτι τα τηλεφωνα που ειχαμε θα ειναι σε λιγο χωρις νεες εφαρμογες και αναβαθμισεις .
Η Νοκια απο την αρχη δηλωσε οτι θα συνεχιζει να υπστηριζει με εφαρμογες για πολυ καιρο ακομη .. Ηδη εχει βγαλει αρκετες εφαρμογες για το λειτουργικο αλλα αυτην την φορα δινει στους χρηστες των WP 7.8 δυο εφαρμογες που ηταν για πολυ καιρο ζητουμενες απο πολλους χρηστες

Οι εφαρμογες αυτες ειναι το Bluetooth Share Ringtone Maker ...



Οπως φαινεται απο τα ονοματα τους το πρωτο κανει μεταφορα αρχειων μεσω bluetooth κατι που παρα πολλοι χρηστες το ηθελαν απο την αρχη των WP και το δευτερο ειναι η εφαρμογη που φτιαχνει ringtones απο οποιοδηποτε τραγουδι εχουμε στην συλλογη μας ...
Και τα δυο τα δοκιμασα και δουλευουν αψογα (Το ringtone στο HTC Titan με ρομ Dynamic 2.0)

Για οσους εχουν τηλεφωνα Νοκια Lumia η εγκαταστησει καποια Custom Rom με Νοκια στοιχεια μπορουν να κατεβασουν απο το marketplace τις 2 εφαρμογες ..

Bluetooth Share 
Ringtone Maker 

Fun with Social, Windows 8 and Javascript

Tuesday, December 4, 2012

Exploring search driven applications with SharePoint Server 2013

Activating Windows 8 Enterprise and changing the key

If you install Windows 8 Enterprise Edition from MSDN you probably notice that you don’t need to enter a key. But after installation you are required to activate the software and this doesn’t work without entering a key. If you want to enter the key you have to go to command prompt  (remember to run with elevated administrator privileges) and type the following slmgr.vbs -ipk "YOUR_PRODUCT_KEY".

Tags van Technorati: ,,

Sunday, December 2, 2012

Eφαρμογη για Backup Επαφων SMS και εφαρμογων (Custom Roms)


Ενα απο τα σοβαρα θεματα που υπηρχουν οταν κανουμε φλασσαρισμα νεας ΡΟΜ σε WP τηλεφωνα ειναι οτι μεχρι τωρα δεν υπηρχε καμμια εφαρμογη η ευκολος τροπος να κρατησουμε backup απο τις επαφες τα μημυματα τα ημερολογια και αλλες ρυθμισεις (wi-fi κωδικους κλπ). Επισης δεν μπορουσαμε να καρατησουμε ρυθμισεις και δεδομενα εφαρμογων ουτως ωστε ευκολα να περοστουν στην νεα ΡΟΜ μετα το φλασσαρισμα.

Ολα αυτα μεχρι τωρα διοτι η εφαρμογη που εδωσε στο XDA πριν λιγο καιρο ο γνωστος απο τις ΡΟΜ του ultrasot λυνει ολ αυτα τα προβληματα ...


Η εφαρμογη για να τρεξει θελει να εχουμε εγκατεστημενα τα παρακατω :

  • Windows Mobile Device Center
  • Windows Phone 7 SDK (or mini SDK)
  • Πληρη συνδεση με το τηλ μεσω Zune 
  • Kαι μια Custom Rom η τελεφωνο με Full unlock.

Υποστηριζει δε τα εξης :
  • Eπαφες, SMS, Ημερολογια
  • My Documents (εκτος Zune collection)
  • Χαρτες Bing 
  • Λεξικα πληκτρολογιου 
  • Κωδικους WiFi access points 
  • Alarms
Επισης υποστηριζει και αρκετες εφαρμογες για τις οποιες κραταει δεδομενα και ρυθμισεις !!!

Το τελευταιο φλασσαρισμα που εκανα στον Τιτανα μου ηταν η ευκαιρια να την δοκιμασω και τα αποτελεσματα ηταν παραπανω απο εντυπωσιακα.

Πριν το φλασσαρισμα εκανα backup σε ολα τα παραπανω και σε οσες εφαρμογες ηθελα να κρατησω δεδομενα (twitter facebook navigation apps κλπ). Η διαδικασια αν προσθεσουμε και καποιες εφαμρογες κρατει αρκετη ωρα ( στην δικη μου περιπτωση περιπου 1.30 ωρα) και δημιουργει ενα αρχειο με ολα τα δεδομενα.

Μετα το φλασσαρισμα ΠΡΕΠΕΙ να κανουμε τα ακολουθα βηματα για να δουλεψει το restore.

1. Εγκατασταση των λογαρισμων windows live και οποιου αλλου λογ/σμου εχουμε επαφες στο τηλεφωνο μας (google facebook κλπ).
2. Εγκατασταση ολων των εφαρμογων που θελουμε να επαναφερουμε...

Μετα απο αυτο τρεχουμε την εφαρμογή και κανουμε επαναφορα. Μολις τελειωσει η διαδικασια κανουμε μια επανεκινηση στο τηλεφωνο και ειναι ολα εκει.. Οπως ηταν πριν το φλασσαρισμα της νεας ΡΟΜ...

Ειναι μια εφαρμογη που ολοι οσοι περνανε νεες ΡΟΜ στα τηλεφωνα τους ΠΡΕΠΕΙ να εχουν και να χρησιμοποιουν ..

Συνιστάτε ανεπιφυλακτα

Σημειωση: Το λινκ στην αρχικη σελιδα στο XDA δεν δουλευει .. Κατεβαστην απο εδω