Using NAudio/Nlayer to mix two mp3 files - mp3

In reference to this question: NoDriver calling acmFormatSuggest on Azure
My hosting server does not allow me to install anything or register dlls. I am using Naudio to mix to mp3 files and it gave me the error NoDriver calling acmFormatSuggest.
I downloaded and installed Nlayer in my application and modified the code to look like this:
var builderBackground = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
var builderMessage = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
Mp3FileReader mpbacground = new Mp3FileReader(ThumbAudioMP3, builderBackground); Mp3FileReader mpMessage = new Mp3FileReader(stream, builderMessage);
background = WaveFormatConversionStream.CreatePcmStream(mpbacground);
message = WaveFormatConversionStream.CreatePcmStream(mpMessage);
var mixer = new WaveMixerStream32(); var messageOffsetted = new WaveOffsetStream(message, TimeSpan.FromSeconds(0), TimeSpan.Zero, TimeSpan.FromSeconds(seconds));
I get the same NoDriver calling acmFormatSuggest error in the line WaveFormatConversionStream.CreatePcmStream(...
Can someone tell me how I should be doing this? Any documentation on Nlayer?

You don't need the WaveFormatConversionStream.CreatePcmStream lines. The Mp3FileReader classes will already emit PCM.

Related

Download image using Dynamics 365 Web API

I am trying to download the image from Dataverse using Dynamics Web API.
I am able to succeed in that using {{webapiurl}}sample_imageattributedemos(d66ecb6c-4fd1-ec11-a7b5-6045bda5603f)/entityimage/$value
But when I try to download the full/actual size image - I am getting the file with the reduced size - {{webapiurl}}sample_imageattributedemos(d66ecb6c-4fd1-ec11-a7b5-6045bda5603f)/entityimage/$value?fullsize=true.
I tried to download the image using the sample code where additionally I have added CanStoreFullImage = true attribute.
Please find below code snippet for the reference:
CreateAttributeRequest createEntityImageRequest = new CreateAttributeRequest
{
EntityName = _customEntityName.ToLower(),
Attribute = new ImageAttributeMetadata
{
SchemaName = "EntityImage", //The name is always EntityImage
//Required level must be AttributeRequiredLevel.None
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
DisplayName = new Microsoft.Xrm.Sdk.Label("Image", 1033),
Description = new Microsoft.Xrm.Sdk.Label("An image to show with this demonstration.", 1033),
CanStoreFullImage = true,
IsPrimaryImage = false,
}
};
How can I achieve this - to download the full size image using Web API?
the correct syntax is size=full, not fullsize=true
to build such requests you can use my tool Dataverse REST Builder, you can find the operations to deal with Image fields under the Manage Image Data request type

How to get object with google.visualization lib?

I am trying to get the data from google spreadsheet with google.visualization.
I am using this code and it works great, but I hope there is a way to get the same object with just google.visualization (same object but without d3.csvParse). I read the docs but cant find any suitable function (just an example with new google.visualization.DataView(convertedData) => view.getNumberOfRows() etc.)
var googleDataQuery = response.getDataTable().toJSON();
var convertedData = new google.visualization.DataTable(googleDataQuery, 0.5);
var data = d3.csvParse(google.visualization.dataTableToCsv(convertedData))
UPD: d3.csvParse returns an object like [{name:"test1"}, {name:"test2"} .... ]
I think google.visualization can do this somehow so I can skip this part d3.csvParse(google.visualization.dataTableToCsv(convertedData))

Roslyn: How to update a document

I'm new to Visual Studio extensions. I'm developing a Menu Command extension to add a using directive to my class. So far, I could successfully create a new Document object containing the changes:
var syntaxTree = await sourceDocument.GetSyntaxTreeAsync();
var unitRoot = syntaxTree.GetCompilationUnitRoot();
var qualifiedName = SyntaxFactory.ParseName("MyApp.Utilities"); // using MayApp.Utilities
var usingDirective = SyntaxFactory.UsingDirective(qualifiedName);
unitRoot = unitRoot.AddUsings(usingDirective);
var newDocument = sourceDocument.WithSyntaxRoot(unitRoot);
The problem is it doesn't reflect the changes back to the source code (or workspace if it's correct term).
Any idea and suggestion is appreciated.

Roslyn Workspace API : Emit each Project inside Solution to dll

I started to wonder how to emit C# Projects using Workspace API and Compiler API from Rolsyn.
This what I get so far:
var msBuild = MSBuildWorkspace.Create();
var sln = msBuild.OpenSolutionAsync
(#"D:\User\Documents\visual studio 14\Projects\ConsoleApplicationWorkspaces"
+#"\ConsoleApplicationWorkspaces.sln").Result;
foreach (var item in sln.Projects)
{
EmitProject(item);
}
public static async void EmitProject(Project proj)
{
var c = await proj.GetCompilationAsync();
var options = new CSharpCompilationOptions
(OutputKind.DynamicallyLinkedLibrary);
c = c.WithOptions(options);
c = c.AddReferences(proj.MetadataReferences);
var result = c.Emit("my" + proj.Name + ".dll");
Console.WriteLine(r.Success);
}
This code don't work.
According to diagnostic info I didn't add references like "System.Runtime","System.Linq".
Using Workspace API I can get references I need but I guess I still I am adding them wrong.
You shouldn't need to change the options or references that come back from Project.GetCompilationAsync. You should just be able to call Emit directly.
Note that you should emit the projects in topological sort order, which you can get from Solution.GetProjectDependencyService.

OpenOffice SDK: convert document to PDF

I'm trying to build an application to convert documents (word, powerpoint) to PDF using the OpenOffice SDK.
I'm using C++ and all I want the application to do is take an input document filename and and output PDF filename, and do the conversion.
Are there any samples or easy way to get started? Most of the documentation I see is using Java.
You can get an example source code here:
http://forum.openoffice.org/en/forum/viewtopic.php?t=3801
I do this with C#, I share with you hoping it helps:
// Connect to a running office and get the service manager
unoidl.com.sun.star.uno.XComponentContext m_xContext = uno.util.Bootstrap.bootstrap();
var mxMSFactory = (XMultiServiceFactory)m_xContext.getServiceManager();
XComponentLoader desktop = (XComponentLoader)mxMSFactory.createInstance("com.sun.star.frame.Desktop");
XComponentLoader xComponentLoader = (unoidl.com.sun.star.frame.XComponentLoader)desktop;
PropertyValue[] properties = new PropertyValue[1];
properties[0] = new PropertyValue();
properties[0].Name = "Hidden";
properties[0].Value = new uno.Any(true);
XComponent xComponent = xComponentLoader.loadComponentFromURL("file:///YOUR .ODT PATH", "_blank", 0, properties);
XTextDocument xDocument = (XTextDocument)xComponent;
XStorable xStorable = (XStorable)xDocument;
PropertyValue[] storeProps = new PropertyValue[3];
storeProps[0] = new PropertyValue();
storeProps[0].Name = "FilterName";
storeProps[0].Value = new uno.Any("writer_pdf_Export");
storeProps[1] = new PropertyValue();
storeProps[1].Name = "Overwrite";
storeProps[1].Value = new uno.Any(true);
storeProps[2] = new PropertyValue();
storeProps[2].Name = "SelectPdfVersion";
storeProps[2].Value = new uno.Any(1);
xStorable.storeToURL("file:///YOUR PDF PATH", storeProps);
xDocument.dispose();
The right way to start is reading the Developer's Guide.
Good stuff in our business ain't easy.