NAudio: All mixer inputs must have the same WaveFormat - naudio

I converted a WaveProvider16 to a SampleProvider using Pcm16BitToSampleProvider. I then added it to a MixingSampleProvider. The logs did indicate that both are IeeeFloat. But the program halted at the AddMixerInput line and the error was All mixer inputs must have the same WaveFormat.
Any thought of what I have missed?
myWaveProvider = new MyWaveProvider16();
mySampleProvider = new Pcm16BitToSampleProvider(myWaveProvider);
mixerBusWaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(8000, 1);
myMixer = new MixingSampleProvider(mixerBusWaveFormat);
myMixerSampleSource = new MixerSampleSource();
Debug.WriteLine("mySampleProvider waveformat: " + mySampleProvider.WaveFormat.ToString());
Debug.WriteLine("myMixer waveformat: " + myMixer.WaveFormat.ToString());
myMixer.AddMixerInput(mySampleProvider);
Output:
mySampleProvider waveformat: IeeeFloat
myMixer waveformat: IeeeFloat
A first chance exception of type 'System.ArgumentException' occurred in NAudio.dll
An unhandled exception of type 'System.ArgumentException' occurred in NAudio.dll
Additional information: All mixer inputs must have the same WaveFormat

User error: Sample rates mismatched.
This line:
myWaveProvider = new MyWaveProvider16();
should be:
myWaveProvider = new MyWaveProvider16(8000, 1);
Otherwise it defaults to 44100.

Related

Bing API exception: The formatter threw an exception while trying to deserialize the message

I am requesting compaign data via bing api using Python SDK, and this line of code throws a suds.WebFault error
get_keyword_ideas_response = adinsight_service.GetAuctionInsightData(EntityType ='Campaign',EntityIds =entityIds, SearchParameters=search_parameters)
the EntityIds is np.array of accounts. and the search parameters are
(ArrayOfSearchParameter){
SearchParameter[] =
(DateRangeSearchParameter){
EndDate =
(DayMonthAndYear){
Day = 30
Month = 8
Year = 2022
}
StartDate =
(DayMonthAndYear){
Day = 1
Month = 8
Year = 2022
}
},
(AuctionSegmentSearchParameter){
Segment = "Week"
},,
}
the full message of exception is : suds.WebFault: Server raised fault: 'The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/AdInsight/v13:EntityIds. The InnerException message was 'Error in line 6 position 51. Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. '. Please see InnerException for more details.'

Cannot pass parameters into a .rdlc file

I receive an error when running the following code. It throws an error when i try to set the parameters on the report. I looked everywhere but cannot seem to find an answer what I am doing wrong here. Every example has this method to pass parameters. Any insight would be greatly appreciated.
Me.ReportViewer1.Clear()
Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "Stock_Centric.OrderPrint.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(NewMicrosoft.Reporting.WinForms.ReportDataSource("dsOrderItems", dtItems.DefaultView))
Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
Dim paramtr(4) As ReportParameter
paramtr(0) = New ReportParameter("Type", "Sale")
paramtr(1) = New ReportParameter("Company", "Jabu")
paramtr(2) = New ReportParameter("Direction", "Out")
paramtr(3) = New ReportParameter("OrderNum", "53")
paramtr(4) = New ReportParameter("Reference", "Kukashop 123")
ReportViewer1.LocalReport.SetParameters(paramtr)
Me.ReportViewer1.RefreshReport()
Error: System.InvalidCastException: 'Unable to cast object of type 'Microsoft.Reporting.WebForms.ReportParameter[]' to type 'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WinForms.ReportParameter]'.'
All your parameters are in a form of strings?

IndexOutOfRangeException was unhandled by user code in a for loop,

I've researched the other answers here but none of them really fit my case. I've added a table to the database and now I am getting this error. Thing is, it worked on someone else's computer, but in mine, I'm getting the following error. p.s. My connections are fine (in case you wandered):
IndexOutOfRangeException was unhandled by user code
An exception of type `System.IndexOutOfRangeException` occurred in System.Data.dll but was not handled in user code
Additional information: Cannot find table 0.
The offending code is the initializing of int i = 0 in the for loop
Here is my code
tableLayoutPanel1.RowCount = ds.Tables[0].Rows.Count;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[i]["RoleName"].ToString();
tableLayoutPanel1.Controls.Add(lbl);
}

Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]:

<?php
include('connect.php');
$date = $_POST['date'];
$student_ID = $_POST['student_ID'];
$full_name = $_POST['full_name'];
$year_section = $_POST['year_section'];
$payment_description = $_POST['payment_description'];
$amount = $_POST['amount'];
$received_by = $_POST['received_by'];
// query
$sql = "INSERT INTO transaction (date,student_ID,full_name,year_section,payment_description,amount,received_by) VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q>execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,':offff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");
?>
I get the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables
does not match number of tokens' in
C:\xampp\htdocs\recordmanagement\main\reg.php:15 Stack trace: #0
C:\xampp\htdocs\recordmanagement\main\reg.php(15):
PDOStatement->execute(Array) #1 {main} thrown in
C:\xampp\htdocs\recordmanagement\main\reg.php on line 15
In the code I am also unsure about the meaning of these values:
(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft);
I downloaded it from sourcecode, so it was not written by me.
There seems to be a field to much in the query. This:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
should probably be:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd)";
as there is no matching value for the :ft field.
Whether this is because your missing an item in the values or if it's not needed I can't say.

Posting related entities in WCF Rest

I have developed a sample WCF REST service that accepts that creates an "Order" object, the method implementation is as shown below:
[Description("Updates an existing order")]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "/Orders")]
[OperationContract]
public void UpdateOrder(Order order)
{
try
{
using (var context = new ProductsDBEntities())
{
context.Orders.Attach(order);
context.ObjectStateManager.ChangeObjectState(order, System.Data.EntityState.Modified);
context.SaveChanges();
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Order updated successfully.";
}
}
catch (Exception ex)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.InternalServerError;
WebOperationContext.Current.OutgoingResponse.StatusDescription = ex.Message + " " + ((ex.InnerException != null) ? ex.InnerException.Message : string.Empty);
}
}
I am trying to consume this service in a client using the "WCF Rest Starter Kit" assemblies. The client side code to consume the service is as below:
var order = new Order(){
OrderId = Convert.ToInt32(ddlCategories.SelectedItem.Value)
};
order.Order_X_Products.Add(new Order_X_Products { ProductId = 1, Quantity = 10});
order.Order_X_Products.Add(new Order_X_Products { ProductId = 2, Quantity = 10});
var content = HttpContentExtensions.CreateJsonDataContract<Order>(order);
var updateResponse = client.Post("Orders", content);
The below line
var updateResponse = client.Post("Orders", content);
throws the following error:
Server Error in '/' Application.
Specified argument was out of the range of valid values.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value
I have a similar logic to create an order and its working fine.
I also tried by removing the following lines
order.Order_X_Products.Add(new Order_X_Products { ProductId = 1, Quantity = 10});
order.Order_X_Products.Add(new Order_X_Products { ProductId = 2, Quantity = 10});
but still the same error.
Please help me solve this issue.
I have also tried serializing the Order object to XML and changing the RequestFormat of UpdateOrder method to XML. In this case I am getting the following error, if any related entities are populated.
Server Error in '/' Application.
Object graph for type 'WcfRestSample.Models.Common.Order_X_Products' contains cycles and cannot be serialized if reference tracking is disabled.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException: Object graph for type 'WcfRestSample.Models.Common.Order_X_Products' contains cycles and cannot be serialized if reference tracking is disabled.
Source Error:
Line 102:
Line 103: var content = HttpContentExtensions.CreateDataContract<Order> (order);
Line 104: var updateResponse = client.Post("Orders", content);
Line 105:
Line 106:
I want to "Update" an order along with the related "Products" through the "Order_X_Products" mapping table.
There is a post here http://smehrozalam.wordpress.com/2010/10/26/datacontractserializer-working-with-class-inheritence-and-circular-references/ that talks about how to deal with circular references when using the DataContractSerializer.