What happen when I scratch (move the track forward)? Do I raise the
pitch and/or rate of the sample?
Think about what is actually happening: A record contains audio data. The record needle reads the audio data from the record. As the record spins, the playback position changes. (It's very similar to watching the playhead move through an audio file in a digital audio editor.)
When you physically spin the record faster, you are increasing the playback rate. The audio is both quicker and higher in pitch. Increase the playback rate by two and the audio will playback an octave higher.
When you physically spin the record slower, you are decreasing the playback rate. The audio is both slower and lower in pitch. Decrease the playback rate by two and the audio will playback an octave lower.
Records can only modify the audio playback by speeding up or slowing down the physical record, this effects both pitch and playback rate together. Some audio software can change the pitch and rate independently. Record players can not.
(Get a record player and experiment to hear what it sounds like.)
How can I emulate this phenomena with audio processing algorithms?
To emulate a DJ scratching a record you need to be able to adjust the playback rate of the audio as the user is "scratching".
When the user speeds up the record, speed up the playback rate. When the user slows the record, slow the playback rate.
When the user stops the record, stop playback altogether.
When the user spins the record in reverse, reverse the playback.
You don't need to change the pitch of the audio. Changing the playback rate will do that automatically. Any further adjustments to the pitch will sound incorrect.
I don't have any advice with regard to libraries but something like this isn't too difficult to implement if you take your time.