
Arokh
Avatar/Signature-
Posts
124 -
Joined
-
Last visited
Personal Information
-
.NET Preferred Language
C#, VB.NET
Arokh's Achievements
Newbie (1/14)
0
Reputation
-
Hi, I need to parse a specific date format, as fast as possible, since there are around a million of them I need to parse in a go. The date format looks like this: "7/30 17:15:39.140" "7/30 10:07:03.156" After searching for an example on the MSDN I found this: http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [CSharp] string dateString, format; DateTime result; CultureInfo provider = CultureInfo.InvariantCulture; // Parse date and time with custom specifier. dateString = "Sun 15 Jun 2008 8:30 AM -06:00"; format = "ddd dd MMM yyyy h:mm tt zzz"; try { result = DateTime.ParseExact(dateString, format, provider); Console.WriteLine("{0} converts to {1}.", dateString, result.ToString()); } catch(FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); } [/CSharp] So I tried to adapt to my needs but don't seem to get it right. I always get an 'System.FormatException' Here is what I tried: [CSharp] string dateString, format; DateTime result; CultureInfo provider = CultureInfo.InvariantCulture; // Parse date and time with custom specifier. dateString = "2008/7/30 13:52:15.765"; format = "yyyy/MM/DD HH:mm:ss.FFF"; try { result = DateTime.ParseExact(dateString, format, provider); Console.WriteLine("{0} converts to {1}.", dateString, result.ToString()); } catch(FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); } [/CSharp] On another note. Is this faster than: [CSharp] string[] TimeStampParts = logEntry.Split(new Char[] { '/', ' ', ':', '.' }); TimeStamp = new DateTime( (long.Parse(TimeStampParts[5]) + (long.Parse(TimeStampParts[4]) + (long.Parse(TimeStampParts[3]) + (long.Parse(TimeStampParts[2]) + (long.Parse(TimeStampParts[1]) + long.Parse(TimeStampParts[0]) * 30) * 24) * 60) * 60) * 1000) * 10000);[/CSharp] ? If not, are there any methods/tricks I can use to make it faster?
-
Hi, I have an old amplifier which connects to a tuner and a tapeplayer, which are connected though three chinch cables (2xaudio 1xcommunication). Now instead of connecting the com-cable to the tapeplayer, I connected it to a loudspeaker and it was as I have hoped: As soon as I pressed a button on the amp remote, I could hear a signal coming from the loudspeaker. Now the next step of the plan is to connect it to my soundcards line-in port, and then interpret the signal. The problem: I have next to no knowledge about audio processing. I guess I'd have to extract the frequency and the volume level, so I can differenciate between the different buttons pressed or holded. Can anyone point me into the right direction where to start, so I can accomplish this? If you want I can attach a sound sample of different signals. I tried some different source code samples, but I've yet to find one that works: http://www.codeproject.com/KB/audio-video/cswavrec.aspx In this one I always get a nullpointer exception. I already tried the suggestions in the comments but to no avail.
-
Yes, that is exactly what I want, only I'll use that function for >=192bit values.
-
Since it converts every byte by itself to the base of 36, it is not what I need. Lets assume I have a byte array of {1, 0}, now the number I need to convert is not 00000001 & 00000000 but 0000000100000000 (In decimal 256) Your code would produce {"1", "0"} what I need is "74" A quick site to test for lower numbers: http://www.mste.uiuc.edu/users/exner/ncsa/base/default.html But thanks for the nice wiki find, based on that I can simplify my code a bit.
-
Hi, My current situation: After hashing I get a bytearray of 24 bytes, normally one would just convert it to hex which is easy. But now I have to convert it to the base of 36 (0-9 + A-Z), which is not so easy anymore. Is there a simple way to do this? The idea I have come up with seems a bit complex for the problem: [CSharp]public static byte[] ByteMultiply(byte[] b, int x) public static byte[] ByteDivision(byte[] b, int x) public static byte[] ByteAdd(byte[] b, int x) public static byte[] ByteSubstract(byte[] b1, byte[] b2) public static bool ByteEqual(byte[] b, int x) public static bool ByteGreaterThan(byte[] b1, byte[] b2) public static string ToString(byte[] b, int baseNumber) { byte[] baseDigit = new byte[0]; string baseStr = ""; baseDigit = ByteAdd(baseDigit, 1); while(true) { baseDigit = ByteMultiply(baseDigit, baseNumber); if(ByteGreaterThan(baseDigit, b)) break; } baseDigit = ByteDivision(baseDigit, baseNumber); int count; while(!ByteEqual(baseDigit, 1)){ count = 0; while(ByteGreaterThan(b, baseDigit)) { b = ByteSubstract(b, baseDigit); count++; } baseStr += map[count]; baseDigit = ByteDivision(baseDigit, baseNumber); } count = 0; while(ByteGreaterThan(b, baseDigit)) { b = ByteSubstract(b, baseDigit); count++; } baseStr += map[count]; return baseStr; }[/CSharp] Ah, oh well the '[' issue in the CSharp tag is still around.
-
Hi, I've been trying to speed up the calculation of the Tiger hash. Though its said that it is a fast hash function beating sha-1, but I can't get anywhere near the sha-1 speed. While sha-1 is limited by my HDD speed at about ~120mb/s, the Tiger hash is limited by my cpu and the speed drops down to ~42mb/s. I've attached the current version for the Tiger hash algorithm I'm using, or view it here Going by this site the Tiger hash should be considerately faster. I know those hashes are highly optimized, but isn't there a way to get more speed in my code in C#? Tiger.zip
-
Hi, I've been searching for a specific library which fits my need and now I finally found it, but I can't get it to work :/ The first problem was I forgot to change the settings from Any CPU to 86x, but as soon as I git rid of that error another came: System.IO.FileLoadException was unhandled Message="Could not load file or assembly 'AvDnCpp, Version=0.7.2526.26249, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1)" Source="CsOutputExample" FileName="AvDnCpp, Version=0.7.2526.26249, Culture=neutral, PublicKeyToken=null" FusionLog="" StackTrace: at CsOutputExample..ctor(String args0) at CsOutputExample.Main(String[] args) in D:\My Stuff\Downloads\AVDump2\avdn_v0_7\CsOutputExample\CsOutputExample.cs:line 24 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Runtime.InteropServices.COMException Message="The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1)" ErrorCode=-2147010895 InnerException: Event Vier log: Activation context generation failed for "D:\My Stuff\Downloads\AVDump2\avdn_v0_7\CsOutputExample\bin\Debug\AvDnCpp.dll". Dependent Assembly Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50608.0" could not be found. Please use sxstrace.exe for detailed diagnosis. Here is the library (it has an example included): http://www.informikon.com/downloads/informikon/tutorials/avdn_v0_7.zip After it has compiled, you should be able to drop a video file over it (CsAvcodecSample.exe), which then results in 5 bmp files in the working directory, representing the first 5 frames of that video file.
-
Hi, Is there any way to detect silent audio channels? I have some bogus video/audio files (avi, mkv, ogm, etc) which have mostly AC3 audio streams with 6 channels. The problem ist they only have 2 channels which contain actual audio data, the other channels are just silent. I need a way to detect that. Is there a simple way to do this? I don't want to get each and every library to demux the audio stream from the container and then get a library which can read that specific audio stream to check if there are some silent channels. It may be as hacked together as it needs to be if it gets the job done. Maybe it could be possible through some media players? (I have the needed codecs & splitters already installed to be able to play those files, but is there any way to take advantage of that?)
-
Hashing a file with different hashes in one go
Arokh replied to Arokh's topic in Directory / File IO / Registry
I think I've got it to work. Hopefully there aren't any bugs left which only happen by chance. If anyones interested: http://pastebin.com/f5fb69518 -
Hashing a file with different hashes in one go
Arokh replied to Arokh's topic in Directory / File IO / Registry
I think I almost got it with the Circular Buffer idea based on: http://en.wikipedia.org/wiki/Circular_buffer#Absolute_indices But somehow everytime it appends data from previous streamreads, and if I try to fix it I get an endless loop. Here is the code I'm using so you know what I'm talking about: http://pastebin.com/f690fd7b2 (CSharp code tag seems to be a little broken) To start it, copy paste of the code should do. The testcode which shows my problem (Program class), creates a testfile ("Test.txt") filled with a pattern. Then 4 readers which read from the circular buffer put everything they get into a new file "Test{ReaderIndex}.txt". Now the resulting files should be exactly the same, but they are 32kb bigger. (2 Blocks in the Circular Buffer) Has anybody an idea what I'm doing wrong? -
Hi, I'm currently writing a application which calculates different hashes. Every hash I "have" has inheritet the HashAlgorithm class and now I want to use them to calculate those hashes. And I want it to be calculated as fast as possible. At first I thought it wouldn't be so hard to do so, but I guess I was wrong. Since I have 4 cores I wanted to make 4 threads. Each thread would be responsible for calculating a hash. Then I have a main loop which reads from the file, then "passes" the data onto the threads, and tell it to calculate the next part of the hash. But I keep on having something like synchronisation problems. And everytime I try to rewrite it I end up with something that doesn't work, it is starting to frustrate me :-\ . Is there a basic "guideline" I can use? I'm currently looking into a circular buffer. If I fail again I'll post the code of it here, so you can give some advice if you want.
-
Well it is no commercial project, it is rather a personal one, but I would like to think that other people will use it too. (Since there are currently only discontinued or "not so good" alternatives, my chances aren't even that bad. :rolleyes: ) Is it really a bad idea to write the framework that way it doesn't involve with any specific application logic? Then writing the base modules which defines what the program has to do. (GUI, backend logic etc) And then giving the user the API (interfaces) to those basic modules. But I guess you are right. I'll just continue to write it and I'll see where I end up :) . ... but I guess not today, my (wannabe) server just gave up on me. Hopefully nothing bad.
-
woah Diesel, slow down. This is a one man project and my first time trying to make an application which is completely based on modules. So I know there I limits to what I can achieve in a short period of time. Either way, I'm still interested in your criticism: Thats the way I'm currently doing it, at least the gist of it: The plugin writer compiles a dll which implements the IMod interface (Main Lib), the (my) program then looks in dll files (placed the plugin dir) for that interface. If it find the implemented interface it creates an instance of it. (Of course there will be some controls like disabling, loading etc for modules) But the instancing phase is not the one where the plugin actually start, it should just do its "preparations" (at least I want to design it that way). The actual part where everything should start is when I call the plugins initialization method (a method in IMod interface). I don't quiet understand. In what way am I hindering the writer to extend the plugin beyond that interface? Since he/she can still implement, inherit other classes. The interface only allows me, the plugin writer, to easily communicate with other modules currently loaded in the application. Well, how that is done, is up to the plugin. (If there is no module loaded the application would do nothing, everything is module based even the GUI, of course I'm writing those modules too) That is a nice idea which I will take into consideration, maybe when I redesign it again I will use that approach. I've been using instanceof() to see if the plugin has implemented another interface (besides IMod) which is able to "manipulate" the GUI. As I before in this post of course there will be controls to disable, enable plugins. I just wanted to point out the two phases I want the plugin to go through when it starts. Preparations - Instantiation Starting - Initialization (IMod method) I never did, as I said I'm an one man army (of rekruts :D ) and I know that I can't make it perfect the first time around. I guess the first thing I will be doing it like you & PlausiblyDamp said, creating a library where only the needed interfaces are in it.
-
Jep works nicely, at least it looks much better than loading it twice. I'm still a bit puzzled as to why the event AssemblyResolve is fired to begin with. It looks random to me because at first the event was fired for most of the assemblies I load, now it fires three times for one module. OK I guess I understand why three times (three modules want an instance of a class from that loaded assembly), but there is alot more loading going on. So why doesn't the event fire for the other ones?
-
In the course of coding a plugin based application (which is progressing very well), I sometimes worry about the aspects of Extensibility & Flexiblity. Plugins may communicate with other plugins so it obviously relies heavily on interfaces. My current (project)structure is like this: Executable Central point for loading & storing modules Provides methods so modules can load other instanciated modules Implements an interface which exposes those methods (Located in main library) Main library Has to be referenced by every module Common tools (classes, methods, etc) Contains IMod interface (base requirement for a module) Contains interfaces of (standart)modules which come with the application Module Has to implement IMod interface May get other module instances So basically when the application starts, it creates an instance of every class that implements the IMod interface. Then it calls the method Initialize (IMod method), passing it the instance of the executable. Now to the actual problem: If I were to change/add/remove something from the main library, wouldn't that break every module which uses the old version of that library?