I am using Yamaha P45 digital piano. I have read at a few places that recording piano is possible without an audio interface, we can directly connect it to laptop and record in audacity. So I bought an aux cable and an audio splitter. I tried doing the same but I failed to record it. What could be the problem? Do you need some special settings in audacity software?
You may consider the following two-step approach:
Record the MIDI messages from the digital piano.
Render the MIDI to an audio track.
Step 1 means that instead of recording the sound that has already been rendered by the MIDI synth on the piano itself, you record the MIDI messages. I'm not familiar with that particular piano, so I don't know if a regular USB cable is enough for connecting the piano to the computer (probably yes), or do you need a MIDI-to-USB cable (needed with older keyboards).
In any case, the result is a MIDI file, or the equivalent of a MIDI file depending on the software you use.
Step 2 involves rendering the MIDI file (or equivalent) into an audio file. And that can be done using software or hardware synthesizers.
In any case having the MIDI file of your playing allows you to try using many different sampled piano sounds, and potentially achieve extremely high quality sound results, which you would not get (in terms of quality and flexibility of use) if you just record the sound itself out of your piano.