|
Wave format does not know about "byte arrays". The format is specified by samples per second (in your case: 11025 vs. 8000), bits per sample (32 vs. 16), sample type (floating point vs. whole number - 32 bit is typically float while 16bit is typically an Int16), and channels (you did not provide any information about that - mono, stereo, something else?).
Look at the source code of NAudio, though they start with files, they soon continue with streams.
|
|
|
|
|
hi guys,
I used memery stream to resample with Naudio.
I write all wave header but i have a problem, my Subchunk2ID (offset 36 ) is too big.
My length wave file is about 20 Hours but when Im playing it's the good lenght (4/3 second).
i checked and its when i write "Data"... what am I missing
bwl.Write(new char[4] { 'R', 'I', 'F', 'F' });
bwl.Write(length);
bwl.Write(new char[8] { 'W', 'A', 'V', 'E', 'f', 'm', 't', ' ' });
bwl.Write((int)16);
bwl.Write((short)1);
bwl.Write(program.channels);
bwl.Write(program.samplerate);
bwl.Write((int)(program.samplerate * ((program.BitsPerSample * program.channels) / 8)));
bwl.Write((short)((program.BitsPerSample * program.channels) / 8));
bwl.Write(program.BitsPerSample);
bwl.Write(new char[4] { 'd', 'a', 't', 'a' });
bwl.Write(buffer);
This line
bwl.Write(new char[4] { 'd', 'a', 't', 'a' });
is 10 times bigger than the initial file !!!!
|
|
|
|
|
How to get the dns suffix name I need to add this suffix to hostname.
|
|
|
|
|
Which DNS suffix? Please give proper details of what you are trying to do, and what part of your code is not working.
|
|
|
|
|
my current machine dns suffixname.I would like to connect to remote host through tcp protocol socket.
|
|
|
|
|
Your DNS suffix is not going to help you to connect to a remote host; you need to know the name or IP address of the remote system itself.
|
|
|
|
|
anyone know how to use ref to make this work?
i keep getting error on load<item3>(i.Item2);
i tried using ref but it didnt work.
public static List<Tuple<object,string,Type>> DBlist;
DBlist.Add(new Tuple<object, string, Type>(A, "A", typeof(List<Car>)));
DBlist.Add(new Tuple<object, string, Type>(B, "B", typeof(List<Boat>)));
foreach (Tuple<Object, string, Type> i in DBlist)
{
Type temp = i.Item3;
i.Item1 = load<Item3>(i.Item2);
}
public static T load<T>(string tablename)
|
|
|
|
|
What error are you getting? "It didn't work" is hardly enough information for anyone to help you.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
i.Item1 = load<Item3>(i.Item2);
i.Item1 = load<Type>(i.Item2);
|
|
|
|
|
It should be rather
i.Item1 = load<temp>(i.Item2);
or
i.Item1 = load<i.Item3>(i.Item2);
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
So you want to call a generic method with a dynamic type parameter? You'll need to use reflection to do that.
Try something like this:
MethodInfo baseMethod = typeof(YourClass).GetMethod("load",
BindingFlags.Public | BindingFlags.Static,
null,
new[] { typeof(string) },
null);
foreach (Tuple<object, string, Type> i in DBlist)
{
MethodInfo realMethod = baseMethod.MakeGenericMethod(i.Item3);
i.Item1 = realMethod.Invoke(null, new[] { i.Item2 });
}
Where YourClass is the name of the class which contains the load<T> method.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You have several problems, as Richard Deeming noted you can't use the load that way, you'll need to use Reflection.
Also, it looks like you intend to assign the result of the load into the variable referenced by the .Item1 object of the Tuple.
What your code actually does is try to assign into the .Item1 property of the Tuple.
Tuples, once created, cannot be changed. The .Item1 property is get-only.
You might be better off changing the DBList to hold delegates that actually do what you seem to want to happen.
Something like:
public static List<Action> DBList;
DBList.Add(() => A = load<<Car>>("A"));
DBList.Add(() => B = load<Boat>("B"));
foreach (var loader in DBList)
{
loader();
}
public static List<T> load<T>(string tablename)
|
|
|
|
|
I have a web service where I need to create a very large bitmap 15,000 x 15,900 x 32bpp. Code fails on my machine (Parameter is not valid exception). On the IIS server, I can create about 85 or so before I get the Parameter is not valid exception. I do NOT keep all 85 in memory if that was your next question .
Workflow is pretty much:
1) Get image request
2) Create 15,000 x 15,900 x 32bpp bitmap
3) Do stuff to it
4) Convert it to 1bpp and return the bytes
I've changed my code around so I call Dispose() on the various Graphics objects every step of the way the second I don't need them anymore, but no luck. The bitmap in Step #2 has to be 32bpp.
Originally I had 10,000 x 10,900 bitmaps and I could process a whole set without crashing (710+). Unfortunately, QA requested the bitmaps to be 15,000 x 15,900. Trying to see how far I get by dropping to 14,000 x 14,900.
I suspect this has to do with the Large Object Heap fragmentation?
One of the recomendations I've seen on the net is to just create a single 15,000 x 15,900 object and re-use it.
Not sure how that would work in a web service. Each simultaneous request needs a 15,000 x 15,900 bitmap of its own.
Saw there is something in .NET 4.5.1 to compact the large object heap... might try that next if the 14k images don't work.
|
|
|
|
|
Check your project, are you compiling it for x64, or using AnyCPU? In order to make it be a 64 bit app, everything must be set to x64, or AnyCPU and running on a 64 bit box. Then make sure that the process is a 64 bit process.
I am assuming you have already done that.
|
|
|
|
|
Yeah, I'm compiling everything as AnyCPU. I think it's something with the fragmentation.
|
|
|
|
|
SledgeHammer01 wrote: 15,000 x 15,900 x 32bpp. Save it to disk; what's the resulting filesize? A Gb?
SledgeHammer01 wrote: Not sure how that would work in a web service. Is it going to be requested often? What frequency?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
After I convert to 1bpp, the resulting TIF is only 1MB to 2MB, but a 15,000 x 15,000 x 32 bpp is like 800MB to 900MB in memory.
|
|
|
|
|
SledgeHammer01 wrote: like 800MB to 900MB in memory. You could do the operation in a separate appdomain (or a separate executable). One can unload an AppDomain, but a separate executable would have to release it's memory on termination.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Try GC.WaitForPendingFinalizers in addition to GC.Collect and Dispose.
|
|
|
|
|
What code are you using to create the Bitmap?
|
|
|
|
|
I am not sure if there is an easy way to compile the codes. I have created 1 exe and 4 dlls.
The exe relies (depends) on 4 dlls ('a', 'b', 'c', 'd').
Illustration is as shown below:
exe -> 'a' -> 'c' -> 'd'
-> 'b' ----^
The 'd' dll is the lowest level. The 'd' is referenced in 'c' dll. and so on. Also that 'a' and 'b' dlls are referenced in exe.
Now when making changes in 'c' dll, I would compile the exe but the 'c' dll remains previous version, not updated when compiling the exe. I would have to compile each dlls ('a', and 'b') then the exe so that the updated 'c' dll is passed over to the exe.
Now for the question is there the easy way to compile those dlls at once? Thanks!
<edited>: Forgot to add that I'm using Visual Studio 2010
modified 18-Feb-14 12:56pm.
|
|
|
|
|
If you right click on a project in the solution explorer, there's a menu item "Project Dependencies[^]". There you can set which projects a project depends on, and a right compilation order will be figured out based on that.
|
|
|
|
|
Found it.. but not sure how to add items in project dependencies. The thing is that the those dlls are seperated (independent) in other folders... I think I need to put those dll projects in the exe project.
Am I right?
|
|
|
|
|
Thanks! Now that the solution is much easier to work on and compiling! THANKS A HEAP!
|
|
|
|
|
If you're using Visual Studio, you can configure the project dependencies.
Right-click the solution file in Solution Explorer, and choose Properties.
Then go to the "Project Dependencies" set of options.
Set the dependencies so that a depends upon b , and b depends upon c , and so forth.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|