 |
|
 |
Hi,
nice stuff!
besides coding, being listening to Bobby Womack - Secrets (1981) while watching your project! When i read you collect old funky records i got amazed!! I do that too.. funky/disco for ages, being also coding heavily on .NET those days. any e-mail available?
cheers, Nick
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I need to read the wavefile in C#. I tried with your code, but the waveform which i got from Matlab is quite different from the onw i got from showwaveform. Why is that ?
Could you help me in this?
Thanks in advance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Obviously. Take the OnPaint code and get it to draw to a bitmap and return it.
Christian Graus - Microsoft MVP - C++
|
| Sign In·View Thread·PermaLink | 4.40/5 (2 votes) |
|
|
|
 |
|
 |
Thanks. I'll give it a go... Unfortunately, I'm pretty noobish to C# and .NET, so obvious stuff doesn't come to me immediately
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
*grin* Sorry.
The OnPaint method recieves a Graphics object. You can create a bitmap, then a graphics object can be built from that bitmap. From there, just use that graphics object instead of the one passed into OnPaint and you'll draw onto your bitmap. Finally, move that code into a seperate method, and have it return the Bitmap. Then, you're done 
Christian Graus - Microsoft MVP - C++
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks. I got it working. Kind of 
It's weird - the scaling doesn't seem to work with the Graphics object from a BMP object... but it works fine using a panel, or the form itself.
I can't see any major difference other than the fact I'm using a BMP Graphics object instead of a panel's Paint event graphics object (PaintEventArgs.Graphics)
Here is my image implementation:
Private Sub PaintIt() If Not IsNothing(wav) Then Dim pen As Pen = New Pen(Color.Lime) _bmp = New Bitmap(pbWav.Size.Width - 100, pbWav.Size.Height) wav.Draw(Graphics.FromImage(_bmp), pen) pbWav.Image = _bmp End If End Sub
I think it's something to do with this part in the Draw() method:
grfx.PageScale = m_PageScale;
Anyway, any ideas or help appreciated.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Yes, the PageScale does indeed set the scaling. Is your full bitmap being drawn on ? If so, then the picture box was stretching the image for you. Otherwise, you need to look at how the pagescale gets set usually, and reproduce that in your code.
Christian Graus - Microsoft MVP - C++
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Yep, the full bitmap is being drawn on. I tried setting the picture box to auto, normal, center and stretch but it doesn't seem to have any effect.
It looks like the bmp gets drawn with 1px=1 sample. Link to what it looks like:
http://img234.echo.cx/img234/1870/untitled11ek.jpg[^]
The top box is a panel - works nicely. The bottom box is the image. When I use the Zoom, the panel zooms in, but the picture box just stays the same.
Anyway, no drama. I'll keep trying some other things..
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi
I converted and ran the code in VS2005. The runs without an error, however the line and graph is not visible in the main window. I opened "Shortwav.wav", the message at the bottom left shows that the "finished drawing .WAV file", however no image is drawn on the canvas.
Any help would be useful
Cheers, Vimal
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello there
Debug.Assert( m_DataID[0] == 100, "Data ID Not Valid" ); This line is giving me problems with a wavefile I saved in Wavelab. The DataID is 80 . . any clue as to why that would crash the program later on, why it needs to be 100 etc?? This has worked before with a different file . . .
Thanks Carmen Branje Ryerson University Toronto, Canada
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I had the same problem with my own recorded files. The trick is, there sometimes some rubbish bytes inserted between the "format" information (given in bytes etc...) and the "data" information. So what you have to do is, to skip this rubbish and get to the part that writes in hexadecimal, (something like that, look at his other page) 'd' = 100, its the d from data !!! Good luck. I jumperd 12 bytes to jump the rubbish bytes.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
The problem comes from the fact that author of the article (in fact the author of the original C++ class) started from a basic WAV file, in you case the dataId = 102 97 99 116 = "fact" which is MS implementation. The authour is trying to work with a standard uncompressed wav file and he is looking for dataId = 100 97 116 97 = "data", for more information you should read on MS website. You can use instead libsndfile which is a c/c++ open-source library and you can find on code project a wrapper, of course remain the unmanaged code, but to make the job is ok.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi When i tried to zoomin without an image application crashes. Take care of it .. problem is simple. Hopes u will correct it .
BYE KrIsHnAdEvAn.K
krishnadk
|
| Sign In·View Thread·PermaLink | 1.33/5 (3 votes) |
|
|
|
 |
|
 |
Hey there,
Neat gizmo there, btw...
I realize this is a port of an existing codebase, but either a link to the earlier implementation or a brief explanation of what the code is actually doing would be useful. Either that, or some of the pitfalls/problems you had porting the code over...
Just a suggestion
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Thanks for the feedback. Good point, I should have included a link.
Here is a link to the original article written in C++.
The only real trouble I had porting this to C# was that the basis of the implementation in C++ was using structs and pointer math, due to my lack of C#/.NET knowledge it took a little while for me to work out all the details. But that also made it a good excersize!
-pj
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Greetings PJ,
Nice article.
(1) One thing you didn't include that the original author included was the "FIXUP" for files that don't have the 'd','a','t','a' bytes located in the right place. Basically, you need to keep reading bytes until you encounter that section. I had to adapt the code to do this, or it would blow up on some of my WAV files.
(2) Having issues reading 24-bit files. Do you have logic for 24 bit WAV files yet?
(3) You asked why drawing was so slow. I think the answer is you just need to reduce the number of data points when graphing data for a large file. Yeah, it's going to be DOG SLOW graphing MILLIONS of data points. I simplified and rewrote your "Draw()" function like this:
public void Draw(Graphics g, Pen pen ) { // Graphs the Points // Here the Range of the Value is [-32K, 32K] -- I think (JJ) RectangleF visBounds = g.VisibleClipBounds; // Reduce the Number of Points to Graph, If Huge! int Increment = 1; while (m_Data.NumSamples / Increment > 65536) Increment *= 2;
// Do the Graph for (int k = 1; k < m_Data.NumSamples; k += Increment) { float XVal = (float)((double)k * visBounds.Width / m_Data.NumSamples); float YVal = (float)((((double)(m_Data[k] + 32768)) * visBounds.Height) / 65536.0);
g.DrawLine(pen, XVal, visBounds.Height/2, XVal, YVal); // JJ: Not sure about this! if (m_Fmt.Channels == 2) k++; } }
Notice that if the number of data points is > 64K, I just iteratively cut the number of points in half, until it gets down within range. You really don't NEED to graph several million data points anyway--you won't be able to make out the detail!
I didn't look at your ZOOM logic yet...
If you have any improvements available, please keep me in the loop. Love this stuff.
- john zgraf@yahoo.com www.zgrafsoftware.com
|
| Sign In·View Thread·PermaLink | 3.00/5 (3 votes) |
|
|
|
 |
|
 |
HI, MY NAME IS FLÁVIO. I AM OF THE BRAZIL AND I AM INITIATING IN THE DEVELOPMENT AREA. IT WOULD LIKE TO USE ITS COMPONENT “WAVEEDITOR” IN A SOFTWARE PROJECT, HOWEVER, I AM WITH DIFFICULTIES TO LOAD CURVE GRAFICA OF UMA MP3 IN THE COMPONENT. YOU IT COULD HELP ME? IT FORGIVES I BOTHER IT AND ANY ERROR OF LANGUAGE, THEREFORE, I DO NOT SAY ENGLISH. THANK YOU FLÁVIO
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |