Search Results

Search found 43 results on 2 pages for 'musigenesis'.

Page 2/2 | < Previous Page | 1 2 

  • Question about creating device-compatible bitmaps in C#

    - by MusiGenesis
    I am storing bitmap-like data in a two-dimensional int array. To convert this array into a GDI-compatible bitmap (for use with BitBlt), I am using this function: public IntPtr GetGDIBitmap(int[,] data) { int w = data.GetLength(0); int h = data.GetLength(1); IntPtr ret = IntPtr.Zero; using (Bitmap bmp = new Bitmap(w, h)) { for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { Color color = Color.FromArgb(data[x, y]); bmp.SetPixel(x, y, color); } } ret = bmp.GetHbitmap(); } return ret; } This works as expected, but the call to bmp.GetHbitmap() has to allocate memory for the returned bitmap. I'd like to modify this method in two (probably related) ways: I'd like to remove the intermediate Bitmap from the above code entirely, and go directly from my int[,] array to the device-compatible bitmap (i.e. the IntPtr). I presume this would involve calling CreateCompatibleBitmap, but I don't know how to go from that call to actually manipulating the pixel values. This should logically follow from the answer to the first, but I'd also like my method to re-use existing GDI bitmap handles (instead of creating a new bitmap each time). How can I do this? NOTE: I don't really use Bitmap.SetPixel(), as its performance could best be described as "glacial". The code is just for illustration.

    Read the article

  • .NET threading question

    - by MusiGenesis
    Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke(); and this? ThreadStart starter = new ThreadStart(SomeMethod); Thread th = new Thread(starter); th.Start(); Or does the first invoke the method on the current thread while the second invokes it on a new thread?

    Read the article

  • How accurately (in terms of time) does Windows play audio?

    - by MusiGenesis
    Let's say I play a stereo WAV file with 317,520,000 samples, which is theoretically 1 hour long. Assuming no interruptions of the playback, will the file finish playing in exactly one hour, or is there some occasional tiny variation in the playback speed such that it would be slightly more or slightly less (by some number of milliseconds) than one hour? I am trying to synchronize animation with audio, and I am using a System.Diagnostics.Stopwatch to keep the frames matching the audio. But if the playback speed of WAV audio in Windows can vary slightly over time, then the audio will drift out of sync with the Stopwatch-driven animation. Which leads to a second question: it appears that a Stopwatch - while highly granular and accurate for short durations - runs slightly fast. On my laptop, a Stopwatch run for exactly 24 hours (as measured by the computer's system time and a real stopwatch) shows an elapsed time of 24 hours plus about 5 seconds (not milliseconds). Is this a known problem with Stopwatch? (A related question would be "am I crazy?", but you can try it for yourself.) Given its usage as a diagnostics tool, I can see where a discrepancy like this would only show up when measuring long durations, for which most people would use something other than a Stopwatch. If I'm really lucky, then both Stopwatch and audio playback are driven by the same underlying mechanism, and thus will stay in sync with each other for days on end. Any chance this is true?

    Read the article

  • Why do calls to waveOutGetPosition hang?

    - by MusiGenesis
    I'm using the winmm.dll API method waveOutGetPosition to get the current position of the playback of a WAV file. Sometimes this works as expected for me, but eventually one of the calls never returns and my application locks up. I found this thread with a few users who have experienced the same problem: http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/c6a1e80e-4a18-47e7-af11-56a89f638ad7 but no solution. Has anyone run into this problem before?

    Read the article

  • How to eliminate tearing from animation?

    - by MusiGenesis
    I'm running an animation in a WinForms app at 18.66666... frames per second (it's synced with music at 140 BPM, which is why the frame rate is weird). Each cel of the animation is pre-calculated, and the animation is driven by a high-resolution multimedia timer. The animation itself is smooth, but I am seeing a significant amount of "tearing", or artifacts that result from cels being caught partway through a screen refresh. When I take the set of cels rendered by my program and write them out to an AVI file, and then play the AVI file in Windows Media Player, I do not see any tearing at all. I assume that WMP plays the file smoothly because it uses DirectX (or something else) and is able to synchronize the rendering with the screen's refresh activity. It's not changing the frame rate, as the animation stays in sync with the audio. Is this why WMP is able to render the animation without tearing, or am I missing something? Is there any way I can use DirectX (or something else) in order to enable my program to be aware of where the current scan line is, and if so, is there any way I can use that information to eliminate tearing without actually using DirectX for displaying the cels? Or do I have to fully use DirectX for rendering in order to deal with this problem? Update: forgot a detail. My app renders each cell onto a PictureBox using Graphics.DrawImage. Is this significantly slower than using BitBlt, such that I might eliminate at least some of the tearing by using BitBlt?

    Read the article

  • Changing the tint of a bitmap while preserving the overall brightness

    - by MusiGenesis
    I'm trying to write a function that will let me red-shift or blue-shift a bitmap while preserving the overall brightness of the image. Basically, a fully red-shifted bitmap would have the same brightness as the original but be thoroughly red-tinted (i.e. the G and B values would be equal for all pixels). Same for blue-tinting (but with R and G equal). The degree of spectrum shifting needs to vary from 0 to 1. Thanks in advance.

    Read the article

  • Integer array or struct array - which is better?

    - by MusiGenesis
    In my app, I'm storing Bitmap data in a two-dimensional integer array (int[,]). To access the R, G and B values I use something like this: // read: int i = _data[x, y]; byte B = (byte)(i >> 0); byte G = (byte)(i >> 8); byte R = (byte)(i >> 16); // write: _data[x, y] = BitConverter.ToInt32(new byte[] { B, G, R, 0 }, 0); I'm using integer arrays instead of an actual System.Drawing.Bitmap because my app runs on Windows Mobile devices where the memory available for creating bitmaps is severely limited. I'm wondering, though, if it would make more sense to declare a structure like this: public struct RGB { public byte R; public byte G; public byte B; } ... and then use an array of RGB instead of an array of int. This way I could easily read and write the separate R, G and B values without having to do bit-shifting and BitConverter-ing. I vaguely remember something from days of yore about byte variables being block-aligned on 32-bit systems, so that a byte actually takes up 4 bytes of memory instead of just 1 (but maybe this was just a Visual Basic thing). Would using an array of structs (like the RGB example` above) be faster than using an array of ints, and would it use 3/4 the memory or 3 times the memory of ints?

    Read the article

  • Does SQL Server Compact Edition (SqlCe) have a SNAPSHOT table like Oracle Lite?

    - by MusiGenesis
    In Oracle Lite, you can create a SNAPSHOT table which is like a normal table except that it tracks changes to itself. The syntax is CREATE SNAPSHOT TABLE tblWhatever ... and you can perform CRUD operations on it like a normal table. To get the change information, you query the table like this: SELECT * FROM tblWhatever + WHERE ... which returns all the rows in the table (including deleted ones) meeting the WHERE clause, and you can access each row's row_state column as a normal field (which is invisible to a normal SELECT * FROM tblWhatever WHERE ... query). Is there some way to do the same thing with Sql Compact Edition (3.5) - i.e. create a table that tracks changes without using RDA?

    Read the article

  • What's the best way to handle web.config file versions in ASP.Net?

    - by MusiGenesis
    I have an ASP.Net web site (ASPX and ASMX pages) with a single web.config file. We have a development version and a production version. Over time, the web.config files for development and production have diverged substantially. What is the best practice for keeping both versions of web.config in source control (we use Tortoise SVN but I don't think that matters)? It seems like I could add the production web.config file with a name like "web.config.prod", and then when we turnover all the files we would just add the step of deleting the existing web.config and renaming web.config.prod to web.config. This seems hackish, although I'm sure it would work. Is there not some mechanism for dealing with this built in to Visual Studio? It seems like this would be a common issue, but I haven't found any questions (with answers) about this.

    Read the article

  • Can I create and connect to a SQL Server CE database if SQL Server 2005 isn't installed?

    - by MusiGenesis
    Is there any way to do this? Update: Sorry, I should have included more information. I am trying to create and connect to a SQL CE database using System.Data.SqlServerCe in C# running on a PC (i.e. not running on a Windows Mobile device). This code: string connstr = "Data Source=\"" + filename + "\";Persist Security Info=False;"; System.Data.SqlServerCe.SqlCeEngine engine = new SqlCeEngine(connstr); engine.CreateDatabase(); ... works fine on any PC that has SQL Server 2005 installed, but fails on any PC that doesn't have it installed. I'm trying to find out if there's any way to get this to work without installed SQL Server 2005 on the machine.

    Read the article

  • How to use the ListView_GetBkImage macro in C#

    - by MusiGenesis
    How can I use the ListView_GetBkImage macro: http://msdn.microsoft.com/en-us/library/bb761246(v=VS.85).aspx ... from a C#/WinForms application? I think this macro just wraps the SendMessage method, but I'm not sure. I couldn't find any C#-based samples on this. Basically I'm trying to get a LVBKIMAGE ( http://msdn.microsoft.com/en-us/library/bb774742(v=VS.85).aspx ) structure that references the Desktop's background bitmap.

    Read the article

  • Help with optimizing C# function via C and/or Assembly

    - by MusiGenesis
    I have this C# method which I'm trying to optimize: // assume arrays are same dimensions private void DoSomething(int[] bigArray1, int[] bigArray2) { int data1; byte A1; byte B1; byte C1; byte D1; int data2; byte A2; byte B2; byte C2; byte D2; for (int i = 0; i < bigArray1.Length; i++) { data1 = bigArray1[i]; data2 = bigArray2[i]; A1 = (byte)(data1 >> 0); B1 = (byte)(data1 >> 8); C1 = (byte)(data1 >> 16); D1 = (byte)(data1 >> 24); A2 = (byte)(data2 >> 0); B2 = (byte)(data2 >> 8); C2 = (byte)(data2 >> 16); D2 = (byte)(data2 >> 24); A1 = A1 > A2 ? A1 : A2; B1 = B1 > B2 ? B1 : B2; C1 = C1 > C2 ? C1 : C2; D1 = D1 > D2 ? D1 : D2; bigArray1[i] = (A1 << 0) | (B1 << 8) | (C1 << 16) | (D1 << 24); } } The function basically compares two int arrays. For each pair of matching elements, the method compares each individual byte value and takes the larger of the two. The element in the first array is then assigned a new int value constructed from the 4 largest byte values (irrespective of source). I think I have optimized this method as much as possible in C# (probably I haven't, of course - suggestions on that score are welcome as well). My question is, is it worth it for me to move this method to an unmanaged C DLL? Would the resulting method execute faster (and how much faster), taking into account the overhead of marshalling my managed int arrays so they can be passed to the method? If doing this would get me, say, a 10% speed improvement, then it would not be worth my time for sure. If it was 2 or 3 times faster, then I would probably have to do it. Note: please, no "premature optimization" comments, thanks in advance. This is simply "optimization".

    Read the article

  • What is the worst gotcha in C# or .NET?

    - by MusiGenesis
    This question is similar to this one, but focused on C# and .NET. I was recently working with a DateTime object, and wrote something like this: DateTime dt = DateTime.Now; dt.AddDays(1); return dt; // still today's date! WTF? The intellisense documentation for AddDays says it adds a day to the date, which it doesn't - it actually returns a date with a day added to it, so you have to write it like: DateTime dt = DateTime.Now; dt = dt.AddDays(1); return dt; // tomorrow's date This one has bitten me a number of times before, so I thought it would be useful to catalog the worst C# gotchas.

    Read the article

  • scripting fruityloops or propellerheads reason from VB or Python?

    - by interstar
    I have both Fruityloops and Propellerheads Reason software synths on my Windows PC. Any way I can get at and script these from either Visual Basic or Python? Or at least send Midi messages to the synths from code? Update : attempts to use something like a "midi-mapper" (thanks for link MusiGenesis) don't seem to work. I don't think Reason or FL Studio act like standard GM Midi synths. Update 2 : If you're interested in this question, check out this too.

    Read the article

  • Milliseconds in DateTime.Now on .NET Compact Framework always zero? [SOLVED]

    - by Marcel
    Hi all, i want to have a time stamp for logs on a Windows Mobile project. The accuracy must be in the range a hundred milliseconds at least. However my call to DateTime.Now returns a DateTime object with the Millisecond property set to zero. Also the Ticks property is rounded accordingly. How to get better time accuracy? Remember, that my code runs on on the Compact Framework, version 3.5. I use a HTC touch Pro 2 device. Based on the answer from MusiGenesis i have created the following class which solved this problem: /// <summary> /// A more precisely implementation of some DateTime properties on mobile devices. /// </summary> /// <devdoc>Tested on a HTC Touch Pro2.</devdoc> public static class DateTimePrecisely { /// <summary> /// Remembers the start time when this model was created. /// </summary> private static DateTime _start = DateTime.Now; /// <summary> /// Remembers the system uptime ticks when this model was created. This /// serves as a more precise time provider as DateTime.Now can do. /// </summary> private static int _startTick = Environment.TickCount; /// <summary> /// Gets a DateTime object that is set exactly to the current date and time on this computer, expressed as the local time. /// </summary> /// <returns></returns> public static DateTime Now { get { return _start.AddMilliseconds(Environment.TickCount - _startTick); } } }

    Read the article

< Previous Page | 1 2