Dream SoftwareDreamMaker.com Create Software

Windows Phone 8.1

Updated Nokia 928 to Windows Phone 8.1 using Developer Preview. Having some issues with Music - lost my playlists and they don't seem to sync.

Posted on Monday, April 14, 2014 12:00 AM


SharpDX 3D Audio

I replaced XNA Framework with the SharpDX framework since the XNA Framework required a redistributable install.
UPDATE: The SharpDX requires the DirectX install.

using SharpDX;
using SharpDX.Multimedia;
using SharpDX.X3DAudio;
using SharpDX.XAudio2;
======================================

XAudio2 xaudio2;
SoundStream stream;
SourceVoice sourceVoice;

X3DAudio x3dAudio;
WaveFormatExtensible deviceFormat;
======================================

xaudio2 = new XAudio2();
deviceFormat = xaudio2.GetDeviceDetails(0).OutputFormat;
x3dAudio = new X3DAudio(deviceFormat.ChannelMask);

using (var masteringVoice = new MasteringVoice(xaudio2))
{
    // Instantiate X3DAudio
    stream = new SoundStream(File.OpenRead("wavefile.wav"));

    var waveFormat = stream.Format;

    sourceVoice = new SourceVoice(xaudio2, waveFormat);

    int bufferSize = waveFormat.ConvertLatencyToByteSize(60000);
    var audioBuffer = new AudioBuffer { Stream = stream, Flags = BufferFlags.EndOfStream, AudioBytes = bufferSize, LoopCount = AudioBuffer.LoopInfinite };

    sourceVoice.SubmitSourceBuffer(audioBuffer, null);
}
======================================

var emitter = new Emitter
{
    ChannelCount = 1,
    CurveDistanceScaler = float.MinValue,
    OrientFront = new Vector3(0, 0, 1),
    OrientTop = new Vector3(0, 1, 0),

******************************************
    //left
    Position = new Vector3(-1, 0, 0),
    //front left
    Position = new Vector3(-1, 0, 1),
    //front right
    Position = new Vector3(1, 0, 1),
    //right
    Position = new Vector3(1, 0, 0),
    //back right
    Position = new Vector3(1, 0, -1),
    //back left
    Position = new Vector3(-1, 0, -1),
******************************************

    Velocity = new Vector3(0, 0, 0)
};

var listener = new Listener
{
    OrientFront = new Vector3(0, 0, 1),
    OrientTop = new Vector3(0, 1, 0),
    Position = new Vector3(0, 0, 0),
    Velocity = new Vector3(0, 0, 0)
};
// Calculate X3DAudio settings
var dspSettings = x3dAudio.Calculate(listener, emitter, CalculateFlags.Matrix | CalculateFlags.Doppler, 1, deviceFormat.Channels);

// Modify XAudio2 source voice settings
sourceVoice.SetOutputMatrix(1, deviceFormat.Channels, dspSettings.MatrixCoefficients);
sourceVoice.Start();

Posted on Tuesday, March 25, 2014 12:00 AM


ASP.NET MVC 5 Scaffolded Controls

/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
    max-width: 280px;
}
For some reason setting the maximum width of all input, select, and textarea controls to 280 pixels. Find the aforementioned CSS code in Site.css and change it. Such as:
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
    max-width: 600px;
}

Posted on Tuesday, March 25, 2014 12:00 AM


XNA Framework for create virtual audio position / location

I used XNA Framework for create virtual audio position / location.

Vector positioning:
X axis left to right = X to 0 to -X
Y axis top to bottom = Y to 0 to -Y as you would expect
Z axis front to back = -Z to 0 to Z

I used XNA Framework for create virtual audio position / location.

SoundEffect soundEffect;
SoundEffectInstance soundEffectInstance;

soundEffect = SoundEffect.FromStream(TitleContainer.OpenStream("Sounds\wavefile.wav"));
soundEffectInstance = soundEffect.CreateInstance();
soundEffectInstance.IsLooped = true;

//LEFT
soundEffectInstance.Apply3D(new AudioListener { Position = Vector3.Zero }, new AudioEmitter { Position = new Vector3(1, 0, 0) });
//FRONT LEFT
soundEffectInstance.Apply3D(new AudioListener { Position = Vector3.Zero }, new AudioEmitter { Position = new Vector3(1, 0, -1) });
//FRONT RIGHT
soundEffectInstance.Apply3D(new AudioListener { Position = Vector3.Zero }, new AudioEmitter { Position = new Vector3(-1, 0, -1) });
//RIGHT
soundEffectInstance.Apply3D(new AudioListener { Position = Vector3.Zero }, new AudioEmitter { Position = new Vector3(-1, 0, 0) });
//BACK RIGHT
soundEffectInstance.Apply3D(new AudioListener { Position = Vector3.Zero }, new AudioEmitter { Position = new Vector3(-1, 0, 1) });
//BACK LEFT
soundEffectInstance.Apply3D(new AudioListener { Position = Vector3.Zero }, new AudioEmitter { Position = new Vector3(1, 0, 1) });

soundEffectInstance.Play();

Posted on Monday, March 24, 2014 12:00 AM


Entity Framework 6 and System.Security.Permissions.ReflectionPermission under GoDaddy medium trust level

<configuration>
  <system.web>
    <trust level="Full" />
  </system.web>
</configuration>

Posted on Saturday, March 22, 2014 12:00 AM


The model backing the context has changed since the database was created - Entity Framework

If you are working on a Web solution, the best position to write the code is in the Application_Start of your Global.asax.cs file.

protected void Application_Start()
{
  Database.SetInitializer<MyContext>(null);
}

Posted on Saturday, March 22, 2014 12:00 AM


First bike ride of 2014

Got my first bike ride of 2014 in - the season has begun! Yearly total miles to beat from 2013 is 3,611.33 miles.

Posted on Sunday, March 09, 2014 12:00 AM


Xamarin iOS and Visual Studio UI

Create UI (.xib) in XCode (Apple)
Copy to Windows Visual Studio folder / project
VS - include in project
VS - set build properties for the .xib file to InterfaceDefinition

Posted on Thursday, February 27, 2014 8:46 AM


Connect to a Windows folder from a MAC

smb://<computer name>

Then prompt for credentials and then drive

Posted on Thursday, February 27, 2014 8:23 AM


Windows Phone 8 (WP8) send message to Azure Service Bus

public partial class SomePage : PhoneApplicationPage
{
    // Your service bus name
    static string serviceNamespace = string.Empty;

    static string baseAddress = string.Empty;
    static string token = string.Empty;
    const string sbHostName = "servicebus.windows.net";
    const string acsHostName = "accesscontrol.windows.net";

    // Your queue name
    string queueName = string.Empty;

    // Your issuer name
    static string issuerName = string.Empty;

    // Your issuer secret
    static string issuerSecret = string.Empty;

    // Note that the realm used when requesting a token uses the HTTP scheme, even though
    // calls to the service are always issued over HTTPS
    static string realm = string.Empty;

    private void SendMessage(string relativeAddress, string body)
    {
        string fullAddress = baseAddress + relativeAddress + "/messages" + "?timeout=60";

        WebClient webClient = new WebClient();
        webClient.Headers[HttpRequestHeader.Authorization] = token;

        webClient.UploadStringAsync(new Uri(fullAddress), "POST", body, token);
    }

    public SomePage()
    {
        InitializeComponent();
        Loaded += SomePage_Loaded;
    }

    private async void SomePage_Loaded(object sender, RoutedEventArgs e)
    {
        baseAddress = string.Format("https://{0}.{1}/", serviceNamespace, sbHostName);
        string acsEndpoint = string.Format("https://{0}-sb.{1}/WRAPv0.9/", serviceNamespace, acsHostName);
        realm = string.Format("http://{0}.{1}/", serviceNamespace, sbHostName);

        string postdata = string.Format("wrap_name={0}&wrap_password={1}&wrap_scope={2}",
                            Uri.EscapeDataString(issuerName),
                            Uri.EscapeDataString(issuerSecret),
                            Uri.EscapeDataString(realm));

        string strResponse = await post(acsEndpoint, postdata);
        var responseProperties = strResponse.Split('&');
        var tokenProperty = responseProperties[0].Split('=');
        token = Uri.UnescapeDataString(tokenProperty[1]);
        token = string.Format(@"WRAP access_token=\{0}\", token);
    }

    private async Task post(string url, string postdata)
    {
        var request = WebRequest.Create(new Uri(url)) as HttpWebRequest;
        request.ContentType = "application/x-www-form-urlencoded";
        request.Method = "POST";

        byte[] data = Encoding.UTF8.GetBytes(postdata);
        request.ContentLength = data.Length;

        using (var requestStream = await Task.Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, request))
        {
            await requestStream.WriteAsync(data, 0, data.Length);
        }

        WebResponse responseObject = await Task.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, request);
        var responseStream = responseObject.GetResponseStream();
        var sr = new StreamReader(responseStream);
        string received = await sr.ReadToEndAsync();

        return received;
    }

    private void ShowAButton_Click(object sender, RoutedEventArgs e)
    {
        SendMessage(queueName, "Message1");
    }
}

Posted on Wednesday, February 26, 2014 12:00 AM


Show All...