Page 1 of 2 12 LastLast
Results 1 to 40 of 49

Thread: Scratching Wav's [NEARLY RESOLVED]

  1. #1

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Scratching Wav's [NEARLY RESOLVED]

    This DirectSound program that CVMichael hooked me up with is the key to getting what I want in real time. It plays wavs forwards/backwards live on demand as well as changing the speed of the sound live!!!:

    http://www.vbforums.com/attachment.p...chmentid=35597

    To serve as a basis before using 3D turntables I plan on making with DirectX8, I wanna use a scrollbar to scratch any wav in real time. This is what I want it to do. Simply clicking on the scrollbar will pause the sound, but scrolling to the left will play the wav in reverse. Scrolling to the right will play the wav regular. The speed of the sound should come into play in this I think. Either that or you are pretty much scrolling through the buffers. The point is, the faster you scoll to scratch, the faster it should play till you stop dead on its tracks. If you let go of it, then it'll play regularly. I dunno how I'm gonna pull this off.

    Can anyone give me a hand modifing this project to where it can have a scratching feature? Thanks in advance.

  2. #2

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    This thread is so gonna get *bumped* for awhile. I think I pushed the envelope with this problem. It shouldn't seem that advanced. I tried myself but messed up somewhere. So what I'm gonna do is study the code, modify it so I know what's going on, and try figuring a way to play through the buffers manually when using the scrollbar.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Scratching Wav's (Project that is nearly capable is included)

    I'll have a bash at the code too when I get home

    Sounds interesting.

  4. #4

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    Kool. A challenge is always nice. If you are successful you are so getting some rep points.

  5. #5
    Junior Member
    Join Date
    Apr 2005
    Location
    NJ
    Posts
    25

    Re: Scratching Wav's (Project that is nearly capable is included)

    I guess I'll try too, I'm bored as hell anyway...


    Never Pet a Burning Dog.

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's (Project that is nearly capable is included)

    I just noticed you opened another thread.

    I made another update to the DirectSound project, and I made another attachment, and deleted the old one.

    This is the latest one:
    http://www.vbforums.com/attachment.p...chmentid=35599

  7. #7

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    Sweet!!! I'll check it out when I get home from work. I owe you one.

  8. #8

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    The scratching part needs modified big time but it'll serve as a basis till I get my 3D turntables all set up. The circle by the way is suppose to rotate exactly 33.5 rpm. And you can do that by doing this formula:

    360 degrees * 33.5 rpm = 12060 degrees per minute

    12060 degrees per minute / 60 seconds = 201 rotations per second

    201 rotations per second * (1/60 FPS) = 3.35 rotation speed per frame

    It's better to have it rotating based on Time based movement which you can see here http://voodoovb.talosstudios.com/timemodelling.html, so I'll create a sample DJ app using these techniques and we can see how things go then.

  9. #9
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's (Project that is nearly capable is included)

    The circle I made it to rotate at 44 rpm (wich you wrote in my PM). But I did not test if it actually rotates at 44 rpm... by the calculations it should rotate at 44

    The rotation depends on the position in the file, so if you slow the speed of the sound, it rotates slower, wich makes total sense to me...

    I had much difficulty to get the right position because the position jumps. For example if the buffer size it 1 second, then the position on the file will change every one second...
    I had to take the position in the buffer in account also, and that was also difficult because the buffer is split in 2, and the position in the file changes every half buffer, so I had to make some calculations there...
    Also, when you play in reverse, I have to reverse the number of the position of the buffer because, the sound in the buffer actually goes forward even when you play backwards.

    When you scratch, the blue line moves by where the mouse is, and the red line tries to follow the blue line (the movement of your scratching). That was the "trial & error" part I was talking about, it took me a while to get it close to the right position...

    But I did not read your post carefully, you actually wanted to do it with a scrool bar, wich is a lot easyer... when I get home (I'm at work now), I'll try to do it with a scroll bar also.
    Last edited by CVMichael; Apr 14th, 2005 at 06:10 PM. Reason: just some small changes

  10. #10

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    Kool! And while you work on that, I'm currently right now making my 3D spinning vinyl rotate at exactly 33.5 rpm in real time using Time Based Animation.

    I'll upload it to ya when I get done with the basic parts I need. Don't need the tables and mixer just yet.

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Scratching Wav's (Project that is nearly capable is included)

    Also, a record spins at 33 1/3 rpm

  12. #12

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    Oh now you tell me. Must have read it wrong in some DJ forum I'm in over at http://www.trugroovez.com/forum/phpBB2/index.php

    So the rotation speed is actually 3.33333333333333333 per frame to get 33 1/3 rpm assuming you are locked at 60 FPS.

  13. #13
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's (Project that is nearly capable is included)

    How about now ? am I getting there or what ?

    I disabled the circle thing scratching, but I left the circle thing itself to show the movement of the scratch...

    I did not use a scroll bar because of it's limitations, no mouse events, and max value 2^15 (~32000), I used a picture box instead, with a moving line of where the mouse is.

    Anyways, try it, tell me how it is...
    Attached Files Attached Files

  14. #14
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's (Project that is nearly capable is included)

    Quote Originally Posted by Jacob Roman
    Kool! And while you work on that, I'm currently right now making my 3D spinning vinyl rotate at exactly 33.5 rpm in real time using Time Based Animation.
    If you do that, then won't it rotate at the same speed regardless of the song speed ?

    If yes, then what's the point of that, isn't the point to make it more realistic ?

    The way I did mine, it shows by the position in the song, and that's how the real one moves, right ?

  15. #15

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    Oh ignor the 33.5. It's actually 33 1/3 as dglienna pointed out. 33 1/3 would be the regular speed of a song. Changing the pitch will not only affect the speed of the vinyl (ranges from -10 to 10 on my turntables, which actually means 23 1/3 rpm to 43 1/3 rpm) but affect the speed of the wav. Yes I am aiming for realism. Plan on doing some physics with the turntables too such as things like after doing a scratch session and you toss the vinyl forward (Force) faster than 33 1/3 rpm, it'll slowly come back to 33 1/3 rpm. Tossing it backward (Force) will cause the music to play backwards briefly till some torque comes into play and pulls it forward and slowly comes back to 33 1/3 rpm again.

    Also the length of a song or wav will determine the speed of the needle slowly coming towards the vinyl logo. That's gonna be interesting to calculate.

  16. #16
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Scratching Wav's (Project that is nearly capable is included)

    Don't you put the turntable into Neutral to scratch? As I recall, scratching was created at radio stations, where they'd put the tt into Neutral in order to cue up the next song. Then, to play the song, they'd click it into gear when the other song ended. You'd have to allow enough space for the tt to start up and get to speed before the song began, and cue it *right* as the other song was ending.

    (Worked at the high school radio station in the late 70's, before scratching became what it is today)

  17. #17

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's (Project that is nearly capable is included)

    The new scratch project is getting better. Sounds better too. But why have it play warp speed when near or all the way to the left/right?!!

    I was hoping for it to be more like this, where it'll go from buffer to buffer when scratching or playing:

    Note: In this program, set the Hand to 100 and Turntable to 1 for a better scratch sound.
    Attached Files Attached Files

  18. #18
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's (Project that is nearly capable is included)

    Quote Originally Posted by Jacob Roman
    But why have it play warp speed when near or all the way to the left/right?!!
    Because until now I had no idea how scratching really worked... I'm not a Dj... never even seen how a Dj works, only had an idea...

    The program is pretty interesting (though I was kinda afraid to install it, you know, virus or other things that an antivirus cannot detect)

    I'm not sure if I can make it work like that. I have an idea, but it is difficult, and it might not work...
    If I split the buffer in more parts (right now it's in 2 parts), something like 100 parts, or one very small buffer, then if you put the sound right in front of whre it's playing, you might get it to work like that.

    Also, i'm pretty sure the sounds in the app you attached, are complectly loaded in memory, where in my program it loads as it plays...

  19. #19

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Your method of the Picturebox with a line in the middle would probably be better than the prog I uploaded cause you would have more control over your scratch. Of course we can do something similar to the program, such as displaying the sine wav thing they had in there.

    My beta 3D vinyl program is almost complete by the way. Might be done tommorow if there are no problems.

  20. #20
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Scratching Wav's [NEARLY RESOLVED]

    The physics problem got a little harder if you read my last post. It tells exactly how the whole scratching thing works.

  21. #21

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Oh I read it already. The record doesn't have to be in neutral depending on what kind of scratch you are doing. But sometimes it'll end up being neutral when you stop the vinyl with your hand to scratch.

  22. #22

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Working on this problem now

    http://www.vbforums.com/showthread.p...55#post1982355

    And I just figured out mathematically how many seconds per 360 degree rotation when at 33 1/3 rpm, which is how many seconds should pass in your wav (or mp3) after it does a complete rotation.

    Ok, here is how I calculated it:

    After one whole second, 199.9999999 degrees would have passed when rotating at 33 1/3 rpm. To obtain the degrees left over, you do this:

    360 degrees - 199.9999999 dps = 160.0000001 degrees left

    160.0000001 degrees left/ 199.9999999 dps = .8 seconds left

    1 sec + .8 seconds left = 1.8 seconds per 360 rotation

    So 1.8 seconds would pass in your wav for every 360 rotation when rotating at 33 1/3 rpm.

  23. #23

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    *bump*

  24. #24
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Scratching Wav's [NEARLY RESOLVED]

    How many seconds per rotation at 33 1/3rpm
    33 1/3 = 100/3 rpm = 5/9 rotations per second
    so now you get 9/5 = 1.8 seconds per rotation
    This is an exact number, I agree with your result.

    Try not to work with inexact numbers like 199.9999...... or you could accumulate round-off error.

    Can you explain what you are trying to do with the force? This is a very complex situation. I assume the turntable is belt-driven(?) so that force applied by the DJ causes the belt to slip so that the force you need is the friction of the belt on the platter spindle.
    Don't forget the momentum in the platter since these things are usually pretty heavy.
    Do you have a force adjustment the DJ can change?

    Maybe you can assume that the motor always turns at 33 1/3 rpm and the difference between the platter speed and motor speed is all slippage in the belt.

    If you stop the turntable then release it you can calculate the rotational acceleration of the platter if you know the frictional coeffecient and the mass of the platter. (again assuming a constant speed motor)

    Rather than trying to model the turntable exactly, you could fudge some formulas and parameters via trial and error.

  25. #25

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    The standard in turntables that DJ's use is Direct Drive Turntables. Belt Driven was the old style, and doesn't have enough torque to pull it back to speed right away.

    The thing I know I'm gonna need to pull off the physics is Kinetic Energy, Potential Energy, Torque, maybe Mass if needed. Possibly a few other things. Force has already been included because what I learned is that Force in the rotational sense is called Torque

  26. #26
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's [NEARLY RESOLVED]

    Quote Originally Posted by Jacob Roman
    The thing I know I'm gonna need to pull off the physics is Kinetic Energy, Potential Energy, Torque, maybe Mass if needed. Possibly a few other things. Force has already been included because what I learned is that Force in the rotational sense is called Torque
    Waw... isn't it a little too precise what you are doing ?
    If I were you, I would make some kind of formula that is close enough to the real thing, I don't think anyone will spend hours to figureout the difference anyway...

  27. #27

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Trust me, it will be worth it in the end

  28. #28
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Scratching Wav's [NEARLY RESOLVED]

    Nice code Jacob. Very versatile.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  29. #29

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    I didn't do it, CVMichael did it. I'm doing the 3D turntable/physics part

  30. #30
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Scratching Wav's [NEARLY RESOLVED]

    Direct drive hum...
    OK assume the motor supplies a constsnt torque, not true but let's simplify things.
    If you apply a constant torque to the platter it will accelerate until you remove the torque. What keeps the platter from accelerating is the friction of the bearings which applies an opposite torque equal to the motor's torque.

    Now the DJ applies a variable torque with his hand.
    The vectoral sum of all the torques will give you the angular acceleration of the platter if you know the mass of the platter.

    If you put the drive into neutral, then the frictional torque is the only remaining force and the platter decellerates according to the same formula.

    I'll dig out my undergraduate Physics books and see if I can come up with the formula.

  31. #31

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Kool! Any help is appreciated since I'm not much of a physics guru.

  32. #32
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Scratching Wav's [NEARLY RESOLVED]

    The quantity you are interested in is the angular acceleration
    From High School we remember
    F=ma
    So a linear acceleration
    a = Force*mass
    A similar equation for angular acceleration is
    A = torque/(moment of inertia)
    For our platter the moment of inertia is
    I = (mass*radius^2)/2
    so that the angular acceleration is
    A = torque/I = 2*torque/(mass*radius^2)
    make sure to get the units right when you plug in values
    the angular velocity (radians/second) is
    V = Vo + A*t
    So now you can ask the question: If the platter is being held still then released
    How long will it take to spin up to speed?
    Let's say the motor puts out its max torque until desired speed is achieved, then it cuts back to maintain desired spin rate.
    t = (V/torque)*(mass*radius^2)/2
    where V is 33 1/3 rpm in correct units i.e 100/3 rpm = 10/9*Pi radians/sec

    check my math

  33. #33

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    This is what I have so far. No physics or clicking stuff just yet, but it's looking good. I took a digital picture of one of my vinyls so I can have a realistic look and used that as a texture. Only I changed the logo in the middle. It's rotating at the precise speed I'm looking for. I would use the QueryPerformanceCounter API but I had issues with it, so I stuck with the medium res timer, which is the GetTickCount API. It's doing good so far. Works best at fullscreen mode.
    Attached Files Attached Files

  34. #34

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    I have to *bump* this one again.

  35. #35
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Scratching Wav's [NEARLY RESOLVED]

    Just helping your "bump"

    Sorry, I did not have any time to work on your problem, hopefully I'll have more time today after work...

    PS, the vinyl thing is pretty cool, but I was not expecting soooo much code just for that.

    And another thing, just in case you did not think of this. When I did my vinyl thing with one line moving around... when I moved the mouse it was moving a little rough (compared to the real thing, I THINK), I mean in reality you move it with your hand, right ? and when you start to move, you have a little presure/weight, so you can't move it fast right when you start, it's progresive... when you move it with the mouse, it's not progresive (i don't think so, does not seem like it is)

    Anyway, just my 5¢, don't know much about this thing

  36. #36

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    I'll work on the clicking events when I get home. I already have it converted to screen coordinates for the Vertexr_Out() variables, just need to work out the If statements

  37. #37

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Still having problems with it, but it'll be fixed hopefully tommorow. In the mean time, can someone at least help with the Time resolution stuff. Like I said, I had issues with the hi res timer, which is why I used a medium res timer.

    And no it's not a Timer object, noobies
    It's real time I'm working with.

    Here is a snapshot of my beta DJ program. I also plan on adding reflection, lighting, and a nice shine on the vinyl to give it a more realistic look.
    Attached Images Attached Images  

  38. #38
    Banned Psychopathetica's Avatar
    Join Date
    Jan 2005
    Posts
    31

    Re: Scratching Wav's [NEARLY RESOLVED]

    Kinetic Enegy would be this:

    KE = 1/2 * m * v^2

    where m is mass and v is your velocity.

    Potential Energy would be this:

    PE = m * g * h

    where m is mass, g is gravity (9.8 for earth gravity), and h is height. Although in this problem it seems height is irrelivant.

    www.physicsclassroom.com should help you figure this out. I believe it's under the "work, energy, and power" section.

    Nice program so far.

  39. #39
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Scratching Wav's [NEARLY RESOLVED]

    Kinetic Enegy would be this:

    KE = 1/2 * m * v^2

    where m is mass and v is your velocity.

    Potential Energy would be this:

    PE = m * g * h
    These equations are for point masses and can't be used in this situation unless you're willing to perform a little calculus in which case you come up with the equations I stated above.

  40. #40

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Scratching Wav's [NEARLY RESOLVED]

    Ok I'm back. Just bought myself one hell of a hard cover game physics book for like $70. It's called Game Physics by David Eberly. And it's got all the calculus and physics I need to pull this off, but it's gonna take me awhile to figure everything out.

    Yes moeur I'm gonna be using calculus, and lot's of it. I'm gonna simulate Turntablism even if it kills me!

    Here is what I know so far:

    • The normal speed of a turntable assuming the pitch is set at 0, is 33 1/3 rpm
    • After a complete 360 rotation while it's at 33 1/3 rpm, exactly 1.8 seconds would have been played
    • Assuming that the framerate is locked at 60 FPS, it will rotate 3.33333333 degrees per frame and 199.99999999 degrees per second.
    • The mass of a 12" vinyl is 149.685484313965 grams. In weight, it is exactly 0.33 lbs.


    There is so much more I would like to list but it would take awhile. I also know that I'm gonna need friction as well as momentum. Already have the formulas thanks to my new book. With CVMichael and moeur's help, we can make a killer DJ program together. It will take time though.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width